[ObjC] Init NSMutableDictionary with capacity.

It make sense to initialize dictionary with capacity to avoid
reallocation during inserting values to dictionary.

Bug: None
Change-Id: Ic3e73b95a36a39dafb89e57d49e89424eb131b4c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/375960
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Yury Yarashevich <yura.yaroshevich@gmail.com>
Cr-Commit-Position: refs/heads/main@{#43836}
This commit is contained in:
Yury Yarashevich 2025-02-03 11:26:21 +01:00 committed by WebRTC LUCI CQ
parent 34c15bc511
commit 6f17d09dd1

View File

@ -131,9 +131,10 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) {
_type = [NSString stringWithCString:statistics.type()
encoding:NSUTF8StringEncoding];
const std::vector<webrtc::Attribute> attributes = statistics.Attributes();
NSMutableDictionary<NSString *, NSObject *> *values =
[NSMutableDictionary dictionary];
for (const auto &attribute : statistics.Attributes()) {
[NSMutableDictionary dictionaryWithCapacity:attributes.size()];
for (const auto &attribute : attributes) {
NSObject *value = ValueFromStatsAttribute(attribute);
if (value) {
NSString *name = [NSString stringWithCString:attribute.name()