Created
July 18, 2012 21:28
-
-
Save elm4ward/3139043 to your computer and use it in GitHub Desktop.
another not so fast removeObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray* ma = [[NSMutableArray alloc] init]; | |
// about 0.015 seconds | |
for (int i = 0; i<10000; i++) { | |
[ma addObject:[NSString stringWithFormat:@"%@ %d", @"ABC", i]]; | |
} | |
// still slow: takes more than 7 seconds..... | |
__block NSMutableArray* ma2 = [ma mutableCopy]; | |
[ma enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
[ma2 removeObject:obj]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment