From 770db81d2c382b86509778486790d1371676a91f Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Fri, 6 Jan 2023 15:33:59 +0530 Subject: [PATCH] Allocated nsmutablearray with capacity --- .../utils/sources/MPPClassificationResult+Helpers.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mediapipe/tasks/ios/components/containers/utils/sources/MPPClassificationResult+Helpers.mm b/mediapipe/tasks/ios/components/containers/utils/sources/MPPClassificationResult+Helpers.mm index 02ad390cd..78bc0b6a3 100644 --- a/mediapipe/tasks/ios/components/containers/utils/sources/MPPClassificationResult+Helpers.mm +++ b/mediapipe/tasks/ios/components/containers/utils/sources/MPPClassificationResult+Helpers.mm @@ -27,7 +27,7 @@ using ClassificationResultProto = + (MPPClassifications *)classificationsWithProto: (const ClassificationsProto &)classificationsProto { - NSMutableArray *categories = [[NSMutableArray alloc] init]; + NSMutableArray *categories = [NSMutableArray arrayWithCapacity:(NSUInteger)classificationsProto.classification_list().classification_size()]; for (const auto &classification : classificationsProto.classification_list().classification()) { [categories addObject:[MPPCategory categoryWithProto:classification]]; } @@ -48,7 +48,7 @@ using ClassificationResultProto = + (MPPClassificationResult *)classificationResultWithProto: (const ClassificationResultProto &)classificationResultProto { - NSMutableArray *classifications = [[NSMutableArray alloc] init]; + NSMutableArray *classifications = [NSMutableArray arrayWithCapacity:(NSUInteger)classificationResultProto.classifications_size()]; for (const auto &classificationsProto : classificationResultProto.classifications()) { [classifications addObject:[MPPClassifications classificationsWithProto:classificationsProto]]; }