Skip to content

Instantly share code, notes, and snippets.

@elm4ward
Created July 18, 2012 21:28
Show Gist options
  • Save elm4ward/3139043 to your computer and use it in GitHub Desktop.
Save elm4ward/3139043 to your computer and use it in GitHub Desktop.
another not so fast removeObject
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