@@ -19,13 +19,14 @@ #import "OFCountedSet.h" #import "OFCountedSet_hashtable.h" #import "OFNumber.h" #import "OFString.h" #import "OFXMLElement.h" -#import "OFAutoreleasePool.h" #import "OFNotImplementedException.h" + +#import "autorelease.h" static struct { Class isa; } placeholder; @@ -138,41 +139,42 @@ } - (OFString*)description { OFMutableString *ret; - OFAutoreleasePool *pool, *pool2; + void *pool; OFEnumerator *enumerator; size_t i, count = [self count]; id object; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; - pool = [[OFAutoreleasePool alloc] init]; - enumerator = [self objectEnumerator]; + + pool = objc_autoreleasePoolPush(); + enumerator = [self objectEnumerator]; i = 0; - pool2 = [[OFAutoreleasePool alloc] init]; - while ((object = [enumerator nextObject]) != nil) { + void *pool2 = objc_autoreleasePoolPush(); + [ret appendString: object]; [ret appendFormat: @": %zu", [self countForObject: object]]; if (++i < count) [ret appendString: @",\n"]; - [pool2 releaseObjects]; + objc_autoreleasePoolPop(pool2); } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)}"]; [ret makeImmutable]; - [pool release]; + objc_autoreleasePoolPop(pool); return ret; } - copy @@ -185,23 +187,23 @@ return [[OFCountedSet alloc] initWithSet: self]; } - (OFXMLElement*)XMLElementBySerializing { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFAutoreleasePool *pool2; + void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; OFEnumerator *enumerator; id object; element = [OFXMLElement elementWithName: @"OFCountedSet" namespace: OF_SERIALIZATION_NS]; enumerator = [self objectEnumerator]; - pool2 = [[OFAutoreleasePool alloc] init]; while ((object = [enumerator nextObject]) != nil) { + void *pool2 = objc_autoreleasePoolPush(); + OFXMLElement *objectElement; OFString *count; count = [OFString stringWithFormat: @"%zu", @@ -213,18 +215,18 @@ [objectElement addAttributeWithName: @"count" stringValue: count]; [objectElement addChild: [object XMLElementBySerializing]]; [element addChild: objectElement]; - [pool2 releaseObjects]; + objc_autoreleasePoolPop(pool2); } [element retain]; - [pool release]; - [element autorelease]; + + objc_autoreleasePoolPop(pool); - return element; + return [element autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsAndCountUsingBlock: (of_counted_set_enumeration_block_t)block @@ -235,11 +237,11 @@ } #endif - (void)minusSet: (OFSet*)set { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; OFEnumerator *enumerator = [countedSet objectEnumerator]; id object; @@ -256,16 +258,16 @@ while ((object = [enumerator nextObject]) != nil) [self removeObject: object]; } - [pool release]; + objc_autoreleasePoolPop(pool); } - (void)unionSet: (OFSet*)set { - OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; OFEnumerator *enumerator = [countedSet objectEnumerator]; id object; @@ -282,8 +284,8 @@ while ((object = [enumerator nextObject]) != nil) [self addObject: object]; } - [pool release]; + objc_autoreleasePoolPop(pool); } @end