Allocated nsmutablearray with capacity

This commit is contained in:
Prianka Liz Kariat 2023-01-06 15:33:59 +05:30
parent 1edfe3737a
commit 770db81d2c

View File

@ -27,7 +27,7 @@ using ClassificationResultProto =
+ (MPPClassifications *)classificationsWithProto:
(const ClassificationsProto &)classificationsProto {
NSMutableArray *categories = [[NSMutableArray alloc] init];
NSMutableArray<MPPCategory *> *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]];
}