@@ -24,14 +24,15 @@ #import "OFString.h" #import "OFNumber.h" #import "OFArray.h" #import "OFXMLElement.h" #import "OFXMLAttribute.h" -#import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" + +#import "autorelease.h" @implementation OFCountedSet_hashtable + (void)initialize { if (self == [OFCountedSet_hashtable class]) @@ -41,11 +42,11 @@ - initWithSet: (OFSet*)set { self = [self init]; @try { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)countedSet; OFEnumerator *enumerator = [countedSet objectEnumerator]; @@ -65,11 +66,11 @@ while ((object = [enumerator nextObject]) != nil) [self addObject: object]; } - [pool release]; + objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } @@ -135,12 +136,11 @@ - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFAutoreleasePool *pool2; + void *pool = objc_autoreleasePoolPush(); OFArray *objects; OFEnumerator *enumerator; OFXMLElement *objectElement; if (![[element name] isEqual: @"OFCountedSet"] || @@ -151,13 +151,12 @@ objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; enumerator = [objects objectEnumerator]; - pool2 = [[OFAutoreleasePool alloc] init]; - while ((objectElement = [enumerator nextObject]) != nil) { + void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *object; OFXMLAttribute *count; OFNumber *number; object = [[objectElement elementsForNamespace: @@ -173,14 +172,14 @@ [dictionary _setObject: number forKey: [object objectByDeserializing] copyKey: NO]; - [pool2 releaseObjects]; + objc_autoreleasePoolPop(pool2); } - [pool release]; + objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } @@ -203,11 +202,11 @@ } #endif - (void)addObject: (id)object { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); OFNumber *count; count = [[dictionary objectForKey: object] numberByIncreasing]; if (count == nil) @@ -217,22 +216,22 @@ forKey: object copyKey: NO]; mutations++; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)removeObject: (id)object { OFNumber *count = [dictionary objectForKey: object]; - OFAutoreleasePool *pool; + void *pool; if (count == nil) return; - pool = [[OFAutoreleasePool alloc] init]; + pool = objc_autoreleasePoolPush(); count = [count numberByDecreasing]; if ([count sizeValue] > 0) [dictionary _setObject: count forKey: object @@ -240,12 +239,12 @@ else [dictionary removeObjectForKey: object]; mutations++; - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)makeImmutable { } @end