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 committed 2013-02-24 15:19:00 +00:00
1 parent c401e3b55e
commit 0268f9865c
2 files changed
+79 -1

No files matched your search

+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);