@@ -63,27 +63,28 @@ for (i = 0; i < count; i++) { if ([objs[i] isEqual: old]) { [new retain]; [objs[i] release]; objs[i] = new; + + return; } } } -- (id)replaceObjectAtIndex: (size_t)index - withObject: (id)obj +- (void)replaceObjectAtIndex: (size_t)index + withObject: (id)obj { id *objs = [array cArray]; id old; if (index >= [array count]) @throw [OFOutOfRangeException newWithClass: isa]; old = objs[index]; objs[index] = [obj retain]; - - return [old autorelease]; + [old release]; } - (void)replaceObjectIdenticalTo: (id)old withObject: (id)new { @@ -93,10 +94,12 @@ for (i = 0; i < count; i++) { if (objs[i] == old) { [new retain]; [objs[i] release]; objs[i] = new; + + return; } } } - (void)removeObject: (id)obj @@ -111,21 +114,11 @@ [array removeItemAtIndex: i]; mutations++; [obj release]; - /* - * We need to get the C array again as it might have - * been relocated. We also need to adjust the count - * as otherwise we would have an out of bounds access. - * As another object will be at the current index now, - * we also need to handle the same index again, thus we - * decrease it. - */ - objs = [array cArray]; - count--; - i--; + return; } } } - (void)removeObjectIdenticalTo: (id)obj @@ -138,33 +131,22 @@ [array removeItemAtIndex: i]; mutations++; [obj release]; - /* - * We need to get the C array again as it might have - * been relocated. We also need to adjust the count - * as otherwise we would have an out of bounds access. - * As another object will be at the current index now, - * we also need to handle the same index again, thus we - * decrease it. - */ - objs = [array cArray]; - count--; - i--; + return; } } } -- (id)removeObjectAtIndex: (size_t)index +- (void)removeObjectAtIndex: (size_t)index { id old = [self objectAtIndex: index]; - - [self removeNObjects: 1 - atIndex: index]; + [array removeItemAtIndex: index]; + [old release]; - return old; + mutations++; } - (void)removeNObjects: (size_t)nobjects { id *objs = [array cArray], *copy;