From 4c7939b96eddb53f1700edfaea7abe1fa5b0e886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 12 Mar 2015 09:25:39 -0700 Subject: [PATCH] Avoid building a redundant array Followup to 28e28934c74b0f8668020de03caf61d65a9c9842. --- platform/ios/MGLMapView.mm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 76415432e..d9390ef17 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -947,18 +947,17 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; _bundledStyleNames = [NSMutableArray array]; NSArray *bundledStyleNamesWithExtensions = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:stylesPath error:nil]; - // Add satellite raster & "hybrid" (satellite raster + vector contours & labels) NSString *hybridStylePrefix = @"hybrid-"; NSString *satelliteStylePrefix = @"satellite-"; - NSMutableArray *hybridStyleNames = [NSMutableArray array]; - for (NSString *styleName in bundledStyleNamesWithExtensions) { - [_bundledStyleNames addObject:[styleName stringByDeletingPathExtension]]; + for (NSString *fileName in bundledStyleNamesWithExtensions) { + NSString *styleName = [fileName stringByDeletingPathExtension]; + [_bundledStyleNames addObject:styleName]; + // Add satellite raster & "hybrid" (satellite raster + vector contours & labels) if ([styleName hasPrefix:satelliteStylePrefix]) { - [hybridStyleNames addObject:[hybridStylePrefix stringByAppendingString:[[styleName substringFromIndex:[satelliteStylePrefix length]] stringByDeletingPathExtension]]]; + [_bundledStyleNames addObject:[hybridStylePrefix stringByAppendingString:[styleName substringFromIndex:[satelliteStylePrefix length]]]]; } } - [_bundledStyleNames addObjectsFromArray:hybridStyleNames]; } return [NSArray arrayWithArray:_bundledStyleNames];