Faster CPMutableArray removeObjectIdenticalTo:.

About 6-8X speedup by skipping all the `indexOfObjectIdenticalTo:` calls and going straight to JS `indexOf`.
This commit is contained in:
Alexander Ljungberg
2013-02-24 15:19:00 +00:00
parent c401e3b55e
commit 0268f9865c
2 changed files with 79 additions and 1 deletions
+15
View File
@@ -246,6 +246,21 @@ var concat = Array.prototype.concat,
splice.call(self, anIndex, 1);
}
- (void)removeObjectIdenticalTo:(id)anObject
{
var anIndex = indexOf.call(self, anObject);
if (anIndex !== -1)
splice.call(self, anIndex, 1);
}
- (void)removeObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
{
if (!aRange)
[self removeObjectIdenticalTo:anObject];
[super removeObjectIdenticalTo:anObject inRange:aRange];
}
- (void)addObject:(id)anObject
{
push.call(self, anObject);