From 6f17d09dd10e7e9f45f7045795f344e96c202c2f Mon Sep 17 00:00:00 2001 From: Yury Yarashevich Date: Mon, 3 Feb 2025 11:26:21 +0100 Subject: [PATCH] [ObjC] Init NSMutableDictionary with capacity. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Yury Yarashevich Cr-Commit-Position: refs/heads/main@{#43836} --- sdk/objc/api/peerconnection/RTCStatisticsReport.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm index d09d4810b7..68aac57f97 100644 --- a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm +++ b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm @@ -131,9 +131,10 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { _type = [NSString stringWithCString:statistics.type() encoding:NSUTF8StringEncoding]; + const std::vector attributes = statistics.Attributes(); NSMutableDictionary *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()