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
} }
@ -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;
@ -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

View file

@ -280,39 +280,39 @@ handle_printf_atsign (FILE *stream,
+ (NSString*) string + (NSString*) string
{ {
return [[[self alloc] init] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
} }
+ (NSString*) stringWithString: (NSString*)aString + (NSString*) stringWithString: (NSString*)aString
{ {
return [[[self alloc] initWithString: aString] autorelease]; return [[[self allocWithZone: NSDefaultMallocZone()]
initWithString: aString] autorelease];
} }
+ (NSString*) stringWithCharacters: (const unichar*)chars + (NSString*) stringWithCharacters: (const unichar*)chars
length: (unsigned int)length length: (unsigned int)length
{ {
return [[[self alloc] return [[[self allocWithZone: NSDefaultMallocZone()]
initWithCharacters: chars length: length] initWithCharacters: chars length: length]
autorelease]; autorelease];
} }
+ (NSString*) stringWithCString: (const char*) byteString + (NSString*) stringWithCString: (const char*) byteString
{ {
return [[[NSString_c_concrete_class alloc] initWithCString:byteString] return [[[NSString_c_concrete_class allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCString: byteString] autorelease];
} }
+ (NSString*) stringWithCString: (const char*)byteString + (NSString*) stringWithCString: (const char*)byteString
length: (unsigned int)length length: (unsigned int)length
{ {
return [[[NSString_c_concrete_class alloc] return [[[NSString_c_concrete_class allocWithZone: NSDefaultMallocZone()]
initWithCString:byteString length:length] initWithCString: byteString length: length] autorelease];
autorelease];
} }
+ (NSString*) stringWithContentsOfFile: (NSString *)path + (NSString*) stringWithContentsOfFile: (NSString *)path
{ {
return [[[self alloc] return [[[self allocWithZone: NSDefaultMallocZone()]
initWithContentsOfFile: path] autorelease]; initWithContentsOfFile: path] autorelease];
} }
@ -322,8 +322,11 @@ handle_printf_atsign (FILE *stream,
id ret; id ret;
va_start(ap, format); va_start(ap, format);
ret = [[[self alloc] initWithFormat:format arguments:ap] if (format == nil)
autorelease]; ret = nil;
else
ret = [[[self allocWithZone: NSDefaultMallocZone()]
initWithFormat: format arguments: ap] autorelease];
va_end(ap); va_end(ap);
return ret; return ret;
} }
@ -331,9 +334,8 @@ handle_printf_atsign (FILE *stream,
+ (NSString*) stringWithFormat: (NSString*)format + (NSString*) stringWithFormat: (NSString*)format
arguments: (va_list)argList arguments: (va_list)argList
{ {
return [[[self alloc] return [[[self allocWithZone: NSDefaultMallocZone()]
initWithFormat:format arguments:argList] initWithFormat: format arguments: argList] autorelease];
autorelease];
} }
@ -732,9 +734,8 @@ handle_printf_atsign (FILE *stream,
z = fastZone(self); z = fastZone(self);
buf = NSZoneMalloc(z, sizeof(unichar)*aRange.length); buf = NSZoneMalloc(z, sizeof(unichar)*aRange.length);
[self getCharacters: buf range: aRange]; [self getCharacters: buf range: aRange];
ret = [[[self class] alloc] initWithCharactersNoCopy: buf ret = [[[self class] allocWithZone: NSDefaultMallocZone()]
length: aRange.length initWithCharactersNoCopy: buf length: aRange.length fromZone: z];
fromZone: z];
return [ret autorelease]; return [ret autorelease];
} }
@ -1912,7 +1913,8 @@ else
}; };
found=NO; found=NO;
}; };
return [[[NSString alloc] initWithCharactersNoCopy:s length:len fromZone:z] autorelease]; return [[[NSString allocWithZone: NSDefaultMallocZone()]
initWithCharactersNoCopy: s length: len fromZone: z] autorelease];
} }
- (NSString*) lowercaseString - (NSString*) lowercaseString
@ -1924,7 +1926,8 @@ else
s = NSZoneMalloc(z, sizeof(unichar)*(len+1)); s = NSZoneMalloc(z, sizeof(unichar)*(len+1));
for(count=0;count<len;count++) for(count=0;count<len;count++)
s[count]=uni_tolower([self characterAtIndex: count]); s[count]=uni_tolower([self characterAtIndex: count]);
return [[[[self class] alloc] initWithCharactersNoCopy: s return [[[[self class] allocWithZone: NSDefaultMallocZone()]
initWithCharactersNoCopy: s
length: len length: len
fromZone: z] autorelease]; fromZone: z] autorelease];
} }
@ -1938,9 +1941,8 @@ else
s = NSZoneMalloc(z, sizeof(unichar)*(len+1)); s = NSZoneMalloc(z, sizeof(unichar)*(len+1));
for(count=0;count<len;count++) for(count=0;count<len;count++)
s[count]=uni_toupper([self characterAtIndex: count]); s[count]=uni_toupper([self characterAtIndex: count]);
return [[[[self class] alloc] initWithCharactersNoCopy: s return [[[[self class] allocWithZone: NSDefaultMallocZone()]
length: len initWithCharactersNoCopy: s length: len fromZone: z] autorelease];
fromZone: z] autorelease];
} }
// Storing the String // Storing the String
@ -2595,9 +2597,8 @@ else
} }
*upoint = (unichar)0; *upoint = (unichar)0;
ret = [[[[self class] alloc] initWithCharactersNoCopy: u ret = [[[[self class] allocWithZone: NSDefaultMallocZone()]
length: uslen(u) initWithCharactersNoCopy: u length: uslen(u) fromZone: z] autorelease];
fromZone: z] autorelease];
return ret; return ret;
} }
@ -2663,11 +2664,14 @@ else
NSArray *r; NSArray *r;
int i; int i;
a = [[NSMutableArray alloc] initWithCapacity: [paths count]]; a = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
for (i = 0; i < [paths count]; i++) { initWithCapacity: [paths count]];
for (i = 0; i < [paths count]; i++)
{
NSString *s = [paths objectAtIndex: i]; NSString *s = [paths objectAtIndex: i];
while ([s isAbsolutePath]) { while ([s isAbsolutePath])
{
s = [s substringFromIndex: 1]; s = [s substringFromIndex: 1];
} }
s = [self stringByAppendingPathComponent: s]; s = [self stringByAppendingPathComponent: s];
@ -2913,8 +2917,8 @@ else
+ (NSMutableString*) stringWithCapacity: (unsigned)capacity + (NSMutableString*) stringWithCapacity: (unsigned)capacity
{ {
return [[[self alloc] initWithCapacity:capacity] return [[[self allocWithZone: NSDefaultMallocZone()]
autorelease]; initWithCapacity: capacity] autorelease];
} }
/* Inefficient. */ /* Inefficient. */
@ -2922,22 +2926,22 @@ else
length: (unsigned)length length: (unsigned)length
{ {
id n; id n;
n = [[self alloc] initWithCharacters: characters length: length]; n = [[self allocWithZone: NSDefaultMallocZone()]
initWithCharacters: characters length: length];
return [n autorelease]; return [n autorelease];
} }
+ (NSString*) stringWithCString: (const char*)byteString + (NSString*) stringWithCString: (const char*)byteString
{ {
return [[[NSMutableString_c_concrete_class alloc] return [[[NSMutableString_c_concrete_class allocWithZone:
initWithCString:byteString] NSDefaultMallocZone()] initWithCString: byteString] autorelease];
autorelease];
} }
+ (NSString*) stringWithCString: (const char*)byteString + (NSString*) stringWithCString: (const char*)byteString
length: (unsigned int)length length: (unsigned int)length
{ {
return [[[NSMutableString_c_concrete_class alloc] return [[[NSMutableString_c_concrete_class allocWithZone:
initWithCString:byteString length:length] NSDefaultMallocZone()] initWithCString: byteString length: length]
autorelease]; autorelease];
} }
@ -2976,7 +2980,8 @@ else
va_list ap; va_list ap;
id tmp; id tmp;
va_start(ap, format); va_start(ap, format);
tmp = [[NSString alloc] initWithFormat:format arguments:ap]; tmp = [[NSString allocWithZone: NSDefaultMallocZone()]
initWithFormat: format arguments: ap];
va_end(ap); va_end(ap);
[self appendString: tmp]; [self appendString: tmp];
[tmp release]; [tmp release];