Minor optimisations

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4212 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-05-06 14:42:26 +00:00
parent ca128fd084
commit fb7def4cd8
9 changed files with 467 additions and 442 deletions

View file

@ -1,3 +1,14 @@
Thu May 6 17:06:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSString.m: Minor optimisations - use ([-allocWithZone:])
* Source/NSGCString.m: ditto
* Source/NSGDictionary.m: ditto
* Source/NSArray.m: ditto
* Source/NSDictionary.m: ditto
* Source/NSSet.m: ditto
* Source/NSGCountedSet.m: ditto
* Source/NSData.m: ditto
Thu May 6 13:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Thu May 6 13:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/propList.h: new file * Source/propList.h: new file

View file

@ -92,18 +92,19 @@ static Class NSMutableArray_concrete_class;
+ array + array
{ {
return [[[self alloc] init] return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
autorelease];
} }
+ arrayWithArray: (NSArray*)array + arrayWithArray: (NSArray*)array
{ {
return [[[self alloc] initWithArray: array] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithArray: array] autorelease];
} }
+ arrayWithContentsOfFile: (NSString*)file + arrayWithContentsOfFile: (NSString*)file
{ {
return [[[self alloc] initWithContentsOfFile: file] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithContentsOfFile: file] autorelease];
} }
+ arrayWithObject: anObject + arrayWithObject: anObject
@ -111,7 +112,8 @@ static Class NSMutableArray_concrete_class;
if (anObject == nil) if (anObject == nil)
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add nil"]; format: @"Tried to add nil"];
return [[[self alloc] initWithObjects: &anObject count: 1] return [[[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: &anObject count: 1]
autorelease]; autorelease];
} }
@ -206,7 +208,8 @@ static Class NSMutableArray_concrete_class;
[self getObjects: objects]; [self getObjects: objects];
objects[c] = anObject; objects[c] = anObject;
na = [[NSArray alloc] initWithObjects: objects count: c+1]; na = [[NSArray allocWithZone: NSDefaultMallocZone()]
initWithObjects: objects count: c+1];
} }
return [na autorelease]; return [na autorelease];
} }
@ -287,7 +290,8 @@ static Class NSMutableArray_concrete_class;
{ {
NSString *myString; NSString *myString;
myString = [[NSString alloc] initWithContentsOfFile: file]; myString = [[NSString allocWithZone: NSDefaultMallocZone()]
initWithContentsOfFile: file];
if (myString) if (myString)
{ {
id result = [myString propertyList]; id result = [myString propertyList];
@ -317,15 +321,16 @@ static Class NSMutableArray_concrete_class;
{ {
va_list ap; va_list ap;
va_start(ap, firstObject); va_start(ap, firstObject);
self = [[self alloc] initWithObjects: firstObject rest: ap]; self = [[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: firstObject rest: ap];
va_end(ap); va_end(ap);
return [self autorelease]; return [self autorelease];
} }
+ arrayWithObjects: (id*)objects count: (unsigned)count + arrayWithObjects: (id*)objects count: (unsigned)count
{ {
return [[[self alloc] initWithObjects: objects count: count] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: objects count: count] autorelease];
} }
- initWithArray: (NSArray*)array - initWithArray: (NSArray*)array
@ -492,7 +497,8 @@ static Class NSMutableArray_concrete_class;
NSMutableArray *sortedArray; NSMutableArray *sortedArray;
NSArray *result; NSArray *result;
sortedArray = [[NSMutableArray alloc] initWithArray: self]; sortedArray = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
initWithArray: self];
[sortedArray sortUsingFunction: comparator context: context]; [sortedArray sortUsingFunction: comparator context: context];
result = [NSArray arrayWithArray: sortedArray]; result = [NSArray arrayWithArray: sortedArray];
[sortedArray release]; [sortedArray release];
@ -570,14 +576,14 @@ static Class NSMutableArray_concrete_class;
- (NSEnumerator*) objectEnumerator - (NSEnumerator*) objectEnumerator
{ {
return [[[NSArrayEnumerator alloc] initWithArray: self] return [[[NSArrayEnumerator allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithArray: self] autorelease];
} }
- (NSEnumerator*) reverseObjectEnumerator - (NSEnumerator*) reverseObjectEnumerator
{ {
return [[[NSArrayEnumeratorReverse alloc] initWithArray: self] return [[[NSArrayEnumeratorReverse allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithArray: self] autorelease];
} }
- (NSString*) description - (NSString*) description
@ -776,8 +782,8 @@ static NSString *indentStrings[] = {
+ arrayWithCapacity: (unsigned)numItems + arrayWithCapacity: (unsigned)numItems
{ {
return [[[self alloc] initWithCapacity: numItems] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCapacity: numItems] autorelease];
} }
- (BOOL)writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile - (BOOL)writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile

View file

@ -268,46 +268,45 @@ failure:
+ (id) data + (id) data
{ {
return [[[NSDataStatic alloc] initWithBytesNoCopy: 0 length: 0] return [[[NSDataStatic allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytesNoCopy: 0 length: 0] autorelease];
} }
+ (id) dataWithBytes: (const void*)bytes + (id) dataWithBytes: (const void*)bytes
length: (unsigned)length length: (unsigned)length
{ {
return [[[dataMalloc alloc] initWithBytes: bytes length: length] return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytes: bytes length: length] autorelease];
} }
+ (id) dataWithBytesNoCopy: (void*)bytes + (id) dataWithBytesNoCopy: (void*)bytes
length: (unsigned)length length: (unsigned)length
{ {
return [[[dataMalloc alloc] initWithBytesNoCopy: bytes return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
length: length] initWithBytesNoCopy: bytes length: length] autorelease];
autorelease];
} }
+ (id) dataWithContentsOfFile: (NSString*)path + (id) dataWithContentsOfFile: (NSString*)path
{ {
return [[[dataMalloc alloc] initWithContentsOfFile: path] return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfFile: path] autorelease];
} }
+ (id) dataWithContentsOfMappedFile: (NSString*)path + (id) dataWithContentsOfMappedFile: (NSString*)path
{ {
#if HAVE_MMAP #if HAVE_MMAP
return [[[NSDataMappedFile alloc] initWithContentsOfMappedFile: path] return [[[NSDataMappedFile allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfMappedFile: path] autorelease];
#else #else
return [[[dataMalloc alloc] initWithContentsOfMappedFile: path] return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfMappedFile: path] autorelease];
#endif #endif
} }
+ (id) dataWithData: (NSData*)data + (id) dataWithData: (NSData*)data
{ {
return [[[dataMalloc alloc] initWithBytes: [data bytes] return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
length: [data length]] autorelease]; initWithBytes: [data bytes] length: [data length]] autorelease];
} }
- (id) init - (id) init
@ -1006,8 +1005,8 @@ failure:
+ (id) dataWithShmID: (int)anID length: (unsigned)length + (id) dataWithShmID: (int)anID length: (unsigned)length
{ {
#if HAVE_SHMCTL #if HAVE_SHMCTL
return [[[NSDataShared alloc] initWithShmID: anID length: length] return [[[NSDataShared allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithShmID: anID length: length] autorelease];
#else #else
NSLog(@"[NSData -dataWithSmdID:length:] no shared memory support"); NSLog(@"[NSData -dataWithSmdID:length:] no shared memory support");
return nil; return nil;
@ -1017,18 +1016,18 @@ failure:
+ (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length + (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length
{ {
#if HAVE_SHMCTL #if HAVE_SHMCTL
return [[[NSDataShared alloc] initWithBytes: bytes length: length] return [[[NSDataShared allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytes: bytes length: length] autorelease];
#else #else
return [[[dataMalloc alloc] initWithBytes: bytes length: length] return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytes: bytes length: length] autorelease];
#endif #endif
} }
+ (id) dataWithStaticBytes: (const void*)bytes length: (unsigned)length + (id) dataWithStaticBytes: (const void*)bytes length: (unsigned)length
{ {
return [[[NSDataStatic alloc] initWithBytesNoCopy: (void*)bytes return [[[NSDataStatic allocWithZone: NSDefaultMallocZone()]
length: length] autorelease]; initWithBytesNoCopy: (void*)bytes length: length] autorelease];
} }
- (id) initWithBytesNoCopy: (void*)bytes - (id) initWithBytesNoCopy: (void*)bytes
@ -1111,55 +1110,52 @@ failure:
+ (id) data + (id) data
{ {
return [[[mutableDataMalloc alloc] initWithCapacity: 0] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCapacity: 0] autorelease];
} }
+ (id) dataWithBytes: (const void*)bytes + (id) dataWithBytes: (const void*)bytes
length: (unsigned)length length: (unsigned)length
{ {
return [[[mutableDataMalloc alloc] initWithBytes: bytes return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
length: length] initWithBytes: bytes length: length] autorelease];
autorelease];
} }
+ (id) dataWithBytesNoCopy: (void*)bytes + (id) dataWithBytesNoCopy: (void*)bytes
length: (unsigned)length length: (unsigned)length
{ {
return [[[mutableDataMalloc alloc] initWithBytesNoCopy: bytes return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
length: length] initWithBytesNoCopy: bytes length: length] autorelease];
autorelease];
} }
+ (id) dataWithCapacity: (unsigned)numBytes + (id) dataWithCapacity: (unsigned)numBytes
{ {
return [[[mutableDataMalloc alloc] initWithCapacity: numBytes] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCapacity: numBytes] autorelease];
} }
+ (id) dataWithContentsOfFile: (NSString*)path + (id) dataWithContentsOfFile: (NSString*)path
{ {
return [[[mutableDataMalloc alloc] initWithContentsOfFile: path] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfFile: path] autorelease];
} }
+ (id) dataWithContentsOfMappedFile: (NSString*)path + (id) dataWithContentsOfMappedFile: (NSString*)path
{ {
return [[[mutableDataMalloc alloc] initWithContentsOfFile: path] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfFile: path] autorelease];
} }
+ (id) dataWithData: (NSData*)data + (id) dataWithData: (NSData*)data
{ {
return [[[mutableDataMalloc alloc] initWithBytes: [data bytes] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
length: [data length]] initWithBytes: [data bytes] length: [data length]] autorelease];
autorelease];
} }
+ (id) dataWithLength: (unsigned)length + (id) dataWithLength: (unsigned)length
{ {
return [[[mutableDataMalloc alloc] initWithLength: length] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithLength: length] autorelease];
} }
- (const void*) bytes - (const void*) bytes
@ -1501,8 +1497,8 @@ failure:
+ (id) dataWithShmID: (int)anID length: (unsigned)length + (id) dataWithShmID: (int)anID length: (unsigned)length
{ {
#if HAVE_SHMCTL #if HAVE_SHMCTL
return [[[NSMutableDataShared alloc] initWithShmID: anID length: length] return [[[NSMutableDataShared allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithShmID: anID length: length] autorelease];
#else #else
NSLog(@"[NSMutableData -dataWithSmdID:length:] no shared memory support"); NSLog(@"[NSMutableData -dataWithSmdID:length:] no shared memory support");
return nil; return nil;
@ -1512,11 +1508,11 @@ failure:
+ (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length + (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length
{ {
#if HAVE_SHMCTL #if HAVE_SHMCTL
return [[[NSMutableDataShared alloc] initWithBytes: bytes length: length] return [[[NSMutableDataShared allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytes: bytes length: length] autorelease];
#else #else
return [[[mutableDataMalloc alloc] initWithBytes: bytes length: length] return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithBytes: bytes length: length] autorelease];
#endif #endif
} }
@ -2041,20 +2037,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (id) copy - (id) copy
{ {
if (NSShouldRetainWithZone(self, NSDefaultMallocZone())) if (NSShouldRetainWithZone(self, NSDefaultMallocZone()))
return [self retain]; return [self retain];
else else
return [[dataMalloc allocWithZone: NSDefaultMallocZone()] return [[dataMalloc allocWithZone: NSDefaultMallocZone()]
initWithBytes: bytes length: length]; initWithBytes: bytes length: length];
} }
- (id) copyWithZone: (NSZone*)z - (id) copyWithZone: (NSZone*)z
{ {
if (NSShouldRetainWithZone(self, z)) if (NSShouldRetainWithZone(self, z))
return [self retain]; return [self retain];
else else
return [[dataMalloc allocWithZone: z] return [[dataMalloc allocWithZone: z]
initWithBytes: bytes length: length]; initWithBytes: bytes length: length];
} }
- (void) dealloc - (void) dealloc
@ -2110,8 +2106,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{ {
NSData *data; NSData *data;
data = [[NSDataStatic alloc] initWithBytesNoCopy: aBuffer data = [[NSDataStatic allocWithZone: NSDefaultMallocZone()]
length: bufferSize]; initWithBytesNoCopy: aBuffer length: bufferSize];
[self release]; [self release];
return data; return data;
} }
@ -2263,7 +2259,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] mapping failed for %s - %s", thePath, strerror(errno)); NSLog(@"[NSDataMappedFile -initWithContentsOfMappedFile:] mapping failed for %s - %s", thePath, strerror(errno));
close(fd); close(fd);
[self release]; [self release];
self = [dataMalloc alloc]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
self = [self initWithContentsOfFile: path]; self = [self initWithContentsOfFile: path];
} }
close(fd); close(fd);
@ -2320,7 +2316,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s", NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s",
bufferSize, strerror(errno)); bufferSize, strerror(errno));
[self release]; [self release];
self = [dataMalloc alloc]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithBytes: aBuffer length: bufferSize]; return [self initWithBytes: aBuffer length: bufferSize];
} }
@ -2331,7 +2327,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
bufferSize, strerror(errno)); bufferSize, strerror(errno));
bytes = 0; bytes = 0;
[self release]; [self release];
self = [dataMalloc alloc]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithBytes: aBuffer length: bufferSize]; return [self initWithBytes: aBuffer length: bufferSize];
} }
length = bufferSize; length = bufferSize;
@ -2414,7 +2410,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (id) copy - (id) copy
{ {
return [[dataMalloc allocWithZone: NSDefaultMallocZone()] return [[dataMalloc allocWithZone: NSDefaultMallocZone()]
initWithBytes: bytes length: length]; initWithBytes: bytes length: length];
} }
- (id) copyWithZone: (NSZone*)z - (id) copyWithZone: (NSZone*)z
@ -2989,7 +2985,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{ {
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory get failed for %u - %s", bufferSize, strerror(errno)); NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory get failed for %u - %s", bufferSize, strerror(errno));
[self release]; [self release];
self = [mutableDataMalloc alloc]; self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithCapacity: bufferSize]; return [self initWithCapacity: bufferSize];
} }
@ -3000,7 +2996,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory attach failed for %u - %s", bufferSize, strerror(e)); NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory attach failed for %u - %s", bufferSize, strerror(e));
bytes = 0; bytes = 0;
[self release]; [self release];
self = [mutableDataMalloc alloc]; self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithCapacity: bufferSize]; return [self initWithCapacity: bufferSize];
} }
length = 0; length = 0;

View file

@ -142,23 +142,21 @@ static Class NSMutableDictionary_concrete_class;
+ dictionary + dictionary
{ {
return [[[self alloc] init] return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
autorelease];
} }
+ dictionaryWithDictionary: (NSDictionary*)otherDictionary + dictionaryWithDictionary: (NSDictionary*)otherDictionary
{ {
return [[[self alloc] initWithDictionary: otherDictionary] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithDictionary: otherDictionary] autorelease];
} }
+ dictionaryWithObjects: (id*)objects + dictionaryWithObjects: (id*)objects
forKeys: (id*)keys forKeys: (id*)keys
count: (unsigned)count count: (unsigned)count
{ {
return [[[self alloc] initWithObjects: objects return [[[self allocWithZone: NSDefaultMallocZone()]
forKeys: keys initWithObjects: objects forKeys: keys count: count] autorelease];
count: count]
autorelease];
} }
- (unsigned) hash - (unsigned) hash
@ -274,8 +272,8 @@ static Class NSMutableDictionary_concrete_class;
} }
} }
NSAssert (argi % 2 == 0, NSInvalidArgumentException); NSAssert (argi % 2 == 0, NSInvalidArgumentException);
d = [[[self alloc] initWithObjects: objects forKeys: keys d = [[[self allocWithZone: NSDefaultMallocZone()]
count: num_pairs] autorelease]; initWithObjects: objects forKeys: keys count: num_pairs] autorelease];
OBJC_FREE(objects); OBJC_FREE(objects);
OBJC_FREE(keys); OBJC_FREE(keys);
return d; return d;
@ -286,14 +284,14 @@ static Class NSMutableDictionary_concrete_class;
+ dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys + dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys
{ {
return [[[self alloc] initWithObjects: objects forKeys: keys] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: objects forKeys: keys] autorelease];
} }
+ dictionaryWithObject: (id)object forKey: (id)key + dictionaryWithObject: (id)object forKey: (id)key
{ {
return [[[self alloc] initWithObjects: &object forKeys: &key count: 1] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: &object forKeys: &key count: 1] autorelease];
} }
/* Override superclass's designated initializer */ /* Override superclass's designated initializer */
@ -346,7 +344,8 @@ static Class NSMutableDictionary_concrete_class;
{ {
NSString *myString; NSString *myString;
myString = [[NSString alloc] initWithContentsOfFile: path]; myString = [[NSString allocWithZone: NSDefaultMallocZone()]
initWithContentsOfFile: path];
if (myString) if (myString)
{ {
id result; id result;
@ -374,8 +373,8 @@ static Class NSMutableDictionary_concrete_class;
+ dictionaryWithContentsOfFile: (NSString *)path + dictionaryWithContentsOfFile: (NSString *)path
{ {
return [[[self alloc] initWithContentsOfFile: path] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithContentsOfFile: path] autorelease];
} }
- (BOOL) isEqual: other - (BOOL) isEqual: other
@ -418,8 +417,8 @@ static Class NSMutableDictionary_concrete_class;
NSAssert (k[i], NSInternalInconsistencyException); NSAssert (k[i], NSInternalInconsistencyException);
} }
NSAssert (![e nextObject], NSInternalInconsistencyException); NSAssert (![e nextObject], NSInternalInconsistencyException);
return [[[NSArray alloc] initWithObjects: k count: c] return [[[NSArray allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: k count: c] autorelease];
} }
- (NSArray*) allValues - (NSArray*) allValues
@ -434,8 +433,8 @@ static Class NSMutableDictionary_concrete_class;
NSAssert (k[i], NSInternalInconsistencyException); NSAssert (k[i], NSInternalInconsistencyException);
} }
NSAssert (![e nextObject], NSInternalInconsistencyException); NSAssert (![e nextObject], NSInternalInconsistencyException);
return [[[NSArray alloc] initWithObjects: k count: c] return [[[NSArray allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: k count: c] autorelease];
} }
- (NSArray*) allKeysForObject: anObject - (NSArray*) allKeysForObject: anObject
@ -449,8 +448,8 @@ static Class NSMutableDictionary_concrete_class;
a[c++] = k; a[c++] = k;
if (c == 0) if (c == 0)
return nil; return nil;
return [[[NSArray alloc] initWithObjects: a count: c] return [[[NSArray allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithObjects: a count: c] autorelease];
} }
struct foo { NSDictionary *d; SEL s; IMP i; }; struct foo { NSDictionary *d; SEL s; IMP i; };
@ -717,8 +716,8 @@ static NSString *indentStrings[] = {
+ dictionaryWithCapacity: (unsigned)numItems + dictionaryWithCapacity: (unsigned)numItems
{ {
return [[[self alloc] initWithCapacity: numItems] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCapacity: numItems] autorelease];
} }
/* Override superclass's designated initializer */ /* Override superclass's designated initializer */

View file

@ -590,8 +590,8 @@ static IMP msInitImp; /* designated initialiser for mutable */
} }
*ptr++ = '"'; *ptr++ = '"';
*ptr = '\0'; *ptr = '\0';
result = [[_fastCls._NSGCString alloc] initWithCStringNoCopy: buf result = [[_fastCls._NSGCString allocWithZone: NSDefaultMallocZone()]
length: length+2 fromZone: z]; initWithCStringNoCopy: buf length: length+2 fromZone: z];
[output appendString: result]; [output appendString: result];
[result release]; [result release];
} }

View file

@ -248,7 +248,8 @@
- (NSEnumerator*) objectEnumerator - (NSEnumerator*) objectEnumerator
{ {
return [[[NSGCountedSetEnumerator alloc] initWithSet: self] autorelease]; return [[[NSGCountedSetEnumerator allocWithZone: NSDefaultMallocZone()]
initWithSet: self] autorelease];
} }
- (void) removeObject: (NSObject*)anObject - (void) removeObject: (NSObject*)anObject

View file

@ -290,14 +290,14 @@ myEqual(id self, id other)
- (NSEnumerator*) keyEnumerator - (NSEnumerator*) keyEnumerator
{ {
return [[[NSGDictionaryKeyEnumerator alloc] initWithDictionary: self] return [[[NSGDictionaryKeyEnumerator allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithDictionary: self] autorelease];
} }
- (NSEnumerator*) objectEnumerator - (NSEnumerator*) objectEnumerator
{ {
return [[[NSGDictionaryObjectEnumerator alloc] initWithDictionary: self] return [[[NSGDictionaryObjectEnumerator allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithDictionary: self] autorelease];
} }
- (id) objectForKey: aKey - (id) objectForKey: aKey

View file

@ -72,37 +72,42 @@ static Class NSMutableSet_concrete_class;
+ set + set
{ {
return [[[self alloc] init] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
} }
+ setWithObjects: (id*)objects + setWithObjects: (id*)objects
count: (unsigned)count count: (unsigned)count
{ {
return [[[self alloc] initWithObjects: objects count: count] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: objects count: count] autorelease];
} }
+ setWithArray: (NSArray*)objects + setWithArray: (NSArray*)objects
{ {
return [[[self alloc] initWithArray: objects] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithArray: objects] autorelease];
} }
+ setWithObject: anObject + setWithObject: anObject
{ {
return [[[self alloc] initWithObjects: &anObject count: 1] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: &anObject count: 1] autorelease];
} }
+ setWithObjects: firstObject, ... + setWithObjects: firstObject, ...
{ {
va_list ap; va_list ap;
va_start(ap, firstObject); va_start(ap, firstObject);
self = [[self alloc] initWithObjects: firstObject rest: ap]; self = [[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: firstObject rest: ap];
va_end(ap); va_end(ap);
return [self autorelease]; return [self autorelease];
} }
+ setWithSet: (NSSet*)aSet + setWithSet: (NSSet*)aSet
{ {
return [[[self alloc] initWithSet: aSet] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithSet: aSet] autorelease];
} }
+ allocWithZone: (NSZone*)z + allocWithZone: (NSZone*)z
@ -277,7 +282,8 @@ static Class NSMutableSet_concrete_class;
{ {
k[i] = [e nextObject]; k[i] = [e nextObject];
} }
return [[[NSArray alloc] initWithObjects: k count: c] autorelease]; return [[[NSArray allocWithZone: NSDefaultMallocZone()]
initWithObjects: k count: c] autorelease];
} }
- (id) anyObject - (id) anyObject
@ -427,7 +433,8 @@ static Class NSMutableSet_concrete_class;
+ (id) setWithCapacity: (unsigned)numItems + (id) setWithCapacity: (unsigned)numItems
{ {
return [[[self alloc] initWithCapacity: numItems] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithCapacity: numItems] autorelease];
} }
+ (id) allocWithZone: (NSZone*)z + (id) allocWithZone: (NSZone*)z

File diff suppressed because it is too large Load diff