Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -18,18 +18,18 @@ #define OF_MUTABLE_SET_M #import "OFMutableSet.h" #import "OFDictionary.h" -#import "OFNull.h" #import "OFArray.h" +#import "OFNumber.h" #import "OFAutoreleasePool.h" @implementation OFMutableSet - (void)addObject: (id)object { - [dictionary _setObject: [OFNull null] + [dictionary _setObject: [OFNumber numberWithSize: 1] forKey: object copyKey: NO]; mutations++; } Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -19,12 +19,12 @@ #define OF_SET_M #import "OFSet.h" #import "OFDictionary.h" #import "OFArray.h" -#import "OFNull.h" #import "OFString.h" +#import "OFNumber.h" #import "OFAutoreleasePool.h" @implementation OFSet + set { @@ -68,16 +68,28 @@ return self; } - initWithSet: (OFSet*)set { - self = [super init]; + self = [self init]; @try { - dictionary = [[OFMutableDictionary alloc] - _initWithDictionary: set->dictionary - copyKeys: NO]; + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFNumber *one = [OFNumber numberWithSize: 1]; + OFEnumerator *enumerator = [set objectEnumerator]; + id object; + + /* + * We can't just copy the dictionary as the specified set might + * be a counted set, but we're just a normal set. + */ + while ((object = [enumerator nextObject]) != nil) + [dictionary _setObject: one + forKey: object + copyKey: NO]; + + [pool release]; } @catch (id e) { [self release]; @throw e; } @@ -87,18 +99,21 @@ - initWithArray: (OFArray*)array { self = [self init]; @try { + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFNumber *one = [OFNumber numberWithSize: 1]; id *cArray = [array cArray]; size_t i, count = [array count]; - OFNull *null = [OFNull null]; for (i = 0; i < count; i++) - [dictionary _setObject: null + [dictionary _setObject: one forKey: cArray[i] copyKey: NO]; + + [pool release]; } @catch (id e) { [self release]; @throw e; } @@ -122,21 +137,24 @@ arguments: (va_list)arguments { self = [self init]; @try { - OFNull *null = [OFNull null]; + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFNumber *one = [OFNumber numberWithSize: 1]; id object; - [dictionary _setObject: null + [dictionary _setObject: one forKey: firstObject copyKey: NO]; while ((object = va_arg(arguments, id)) != nil) - [dictionary _setObject: null + [dictionary _setObject: one forKey: object copyKey: NO]; + + [pool release]; } @catch (id e) { [self release]; @throw e; }