mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
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:
parent
ca128fd084
commit
fb7def4cd8
9 changed files with 467 additions and 442 deletions
11
ChangeLog
11
ChangeLog
|
@ -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>
|
||||
|
||||
* Source/propList.h: new file
|
||||
|
|
|
@ -92,18 +92,19 @@ static Class NSMutableArray_concrete_class;
|
|||
|
||||
+ array
|
||||
{
|
||||
return [[[self alloc] init]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
|
||||
}
|
||||
|
||||
+ arrayWithArray: (NSArray*)array
|
||||
{
|
||||
return [[[self alloc] initWithArray: array] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithArray: array] autorelease];
|
||||
}
|
||||
|
||||
+ arrayWithContentsOfFile: (NSString*)file
|
||||
{
|
||||
return [[[self alloc] initWithContentsOfFile: file] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: file] autorelease];
|
||||
}
|
||||
|
||||
+ arrayWithObject: anObject
|
||||
|
@ -111,7 +112,8 @@ static Class NSMutableArray_concrete_class;
|
|||
if (anObject == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Tried to add nil"];
|
||||
return [[[self alloc] initWithObjects: &anObject count: 1]
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: &anObject count: 1]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
|
@ -206,7 +208,8 @@ static Class NSMutableArray_concrete_class;
|
|||
|
||||
[self getObjects: objects];
|
||||
objects[c] = anObject;
|
||||
na = [[NSArray alloc] initWithObjects: objects count: c+1];
|
||||
na = [[NSArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects count: c+1];
|
||||
}
|
||||
return [na autorelease];
|
||||
}
|
||||
|
@ -287,7 +290,8 @@ static Class NSMutableArray_concrete_class;
|
|||
{
|
||||
NSString *myString;
|
||||
|
||||
myString = [[NSString alloc] initWithContentsOfFile: file];
|
||||
myString = [[NSString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: file];
|
||||
if (myString)
|
||||
{
|
||||
id result = [myString propertyList];
|
||||
|
@ -317,15 +321,16 @@ static Class NSMutableArray_concrete_class;
|
|||
{
|
||||
va_list ap;
|
||||
va_start(ap, firstObject);
|
||||
self = [[self alloc] initWithObjects: firstObject rest: ap];
|
||||
self = [[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: firstObject rest: ap];
|
||||
va_end(ap);
|
||||
return [self autorelease];
|
||||
}
|
||||
|
||||
+ arrayWithObjects: (id*)objects count: (unsigned)count
|
||||
{
|
||||
return [[[self alloc] initWithObjects: objects count: count]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects count: count] autorelease];
|
||||
}
|
||||
|
||||
- initWithArray: (NSArray*)array
|
||||
|
@ -492,7 +497,8 @@ static Class NSMutableArray_concrete_class;
|
|||
NSMutableArray *sortedArray;
|
||||
NSArray *result;
|
||||
|
||||
sortedArray = [[NSMutableArray alloc] initWithArray: self];
|
||||
sortedArray = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithArray: self];
|
||||
[sortedArray sortUsingFunction: comparator context: context];
|
||||
result = [NSArray arrayWithArray: sortedArray];
|
||||
[sortedArray release];
|
||||
|
@ -570,14 +576,14 @@ static Class NSMutableArray_concrete_class;
|
|||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
return [[[NSArrayEnumerator alloc] initWithArray: self]
|
||||
autorelease];
|
||||
return [[[NSArrayEnumerator allocWithZone: NSDefaultMallocZone()]
|
||||
initWithArray: self] autorelease];
|
||||
}
|
||||
|
||||
- (NSEnumerator*) reverseObjectEnumerator
|
||||
{
|
||||
return [[[NSArrayEnumeratorReverse alloc] initWithArray: self]
|
||||
autorelease];
|
||||
return [[[NSArrayEnumeratorReverse allocWithZone: NSDefaultMallocZone()]
|
||||
initWithArray: self] autorelease];
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
|
@ -776,8 +782,8 @@ static NSString *indentStrings[] = {
|
|||
|
||||
+ arrayWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [[[self alloc] initWithCapacity: numItems]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: numItems] autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
|
||||
|
|
106
Source/NSData.m
106
Source/NSData.m
|
@ -268,46 +268,45 @@ failure:
|
|||
|
||||
+ (id) data
|
||||
{
|
||||
return [[[NSDataStatic alloc] initWithBytesNoCopy: 0 length: 0]
|
||||
autorelease];
|
||||
return [[[NSDataStatic allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytesNoCopy: 0 length: 0] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytes: (const void*)bytes
|
||||
length: (unsigned)length
|
||||
{
|
||||
return [[[dataMalloc alloc] initWithBytes: bytes length: length]
|
||||
autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytesNoCopy: (void*)bytes
|
||||
length: (unsigned)length
|
||||
{
|
||||
return [[[dataMalloc alloc] initWithBytesNoCopy: bytes
|
||||
length: length]
|
||||
autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytesNoCopy: bytes length: length] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithContentsOfFile: (NSString*)path
|
||||
{
|
||||
return [[[dataMalloc alloc] initWithContentsOfFile: path]
|
||||
autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithContentsOfMappedFile: (NSString*)path
|
||||
{
|
||||
#if HAVE_MMAP
|
||||
return [[[NSDataMappedFile alloc] initWithContentsOfMappedFile: path]
|
||||
autorelease];
|
||||
return [[[NSDataMappedFile allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfMappedFile: path] autorelease];
|
||||
#else
|
||||
return [[[dataMalloc alloc] initWithContentsOfMappedFile: path]
|
||||
autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfMappedFile: path] autorelease];
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (id) dataWithData: (NSData*)data
|
||||
{
|
||||
return [[[dataMalloc alloc] initWithBytes: [data bytes]
|
||||
length: [data length]] autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: [data bytes] length: [data length]] autorelease];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
|
@ -1006,8 +1005,8 @@ failure:
|
|||
+ (id) dataWithShmID: (int)anID length: (unsigned)length
|
||||
{
|
||||
#if HAVE_SHMCTL
|
||||
return [[[NSDataShared alloc] initWithShmID: anID length: length]
|
||||
autorelease];
|
||||
return [[[NSDataShared allocWithZone: NSDefaultMallocZone()]
|
||||
initWithShmID: anID length: length] autorelease];
|
||||
#else
|
||||
NSLog(@"[NSData -dataWithSmdID:length:] no shared memory support");
|
||||
return nil;
|
||||
|
@ -1017,18 +1016,18 @@ failure:
|
|||
+ (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length
|
||||
{
|
||||
#if HAVE_SHMCTL
|
||||
return [[[NSDataShared alloc] initWithBytes: bytes length: length]
|
||||
autorelease];
|
||||
return [[[NSDataShared allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
#else
|
||||
return [[[dataMalloc alloc] initWithBytes: bytes length: length]
|
||||
autorelease];
|
||||
return [[[dataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (id) dataWithStaticBytes: (const void*)bytes length: (unsigned)length
|
||||
{
|
||||
return [[[NSDataStatic alloc] initWithBytesNoCopy: (void*)bytes
|
||||
length: length] autorelease];
|
||||
return [[[NSDataStatic allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytesNoCopy: (void*)bytes length: length] autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithBytesNoCopy: (void*)bytes
|
||||
|
@ -1111,55 +1110,52 @@ failure:
|
|||
|
||||
+ (id) data
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithCapacity: 0]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: 0] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytes: (const void*)bytes
|
||||
length: (unsigned)length
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithBytes: bytes
|
||||
length: length]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithBytesNoCopy: (void*)bytes
|
||||
length: (unsigned)length
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithBytesNoCopy: bytes
|
||||
length: length]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytesNoCopy: bytes length: length] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithCapacity: (unsigned)numBytes
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithCapacity: numBytes]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: numBytes] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithContentsOfFile: (NSString*)path
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithContentsOfFile: path]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithContentsOfMappedFile: (NSString*)path
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithContentsOfFile: path]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithData: (NSData*)data
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithBytes: [data bytes]
|
||||
length: [data length]]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: [data bytes] length: [data length]] autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithLength: (unsigned)length
|
||||
{
|
||||
return [[[mutableDataMalloc alloc] initWithLength: length]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithLength: length] autorelease];
|
||||
}
|
||||
|
||||
- (const void*) bytes
|
||||
|
@ -1501,8 +1497,8 @@ failure:
|
|||
+ (id) dataWithShmID: (int)anID length: (unsigned)length
|
||||
{
|
||||
#if HAVE_SHMCTL
|
||||
return [[[NSMutableDataShared alloc] initWithShmID: anID length: length]
|
||||
autorelease];
|
||||
return [[[NSMutableDataShared allocWithZone: NSDefaultMallocZone()]
|
||||
initWithShmID: anID length: length] autorelease];
|
||||
#else
|
||||
NSLog(@"[NSMutableData -dataWithSmdID:length:] no shared memory support");
|
||||
return nil;
|
||||
|
@ -1512,11 +1508,11 @@ failure:
|
|||
+ (id) dataWithSharedBytes: (const void*)bytes length: (unsigned)length
|
||||
{
|
||||
#if HAVE_SHMCTL
|
||||
return [[[NSMutableDataShared alloc] initWithBytes: bytes length: length]
|
||||
autorelease];
|
||||
return [[[NSMutableDataShared allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
#else
|
||||
return [[[mutableDataMalloc alloc] initWithBytes: bytes length: length]
|
||||
autorelease];
|
||||
return [[[mutableDataMalloc allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: bytes length: length] autorelease];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2110,8 +2106,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
NSData *data;
|
||||
|
||||
data = [[NSDataStatic alloc] initWithBytesNoCopy: aBuffer
|
||||
length: bufferSize];
|
||||
data = [[NSDataStatic allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytesNoCopy: aBuffer length: bufferSize];
|
||||
[self release];
|
||||
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));
|
||||
close(fd);
|
||||
[self release];
|
||||
self = [dataMalloc alloc];
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
self = [self initWithContentsOfFile: path];
|
||||
}
|
||||
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",
|
||||
bufferSize, strerror(errno));
|
||||
[self release];
|
||||
self = [dataMalloc alloc];
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithBytes: aBuffer length: bufferSize];
|
||||
}
|
||||
|
||||
|
@ -2331,7 +2327,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
bufferSize, strerror(errno));
|
||||
bytes = 0;
|
||||
[self release];
|
||||
self = [dataMalloc alloc];
|
||||
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithBytes: aBuffer 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));
|
||||
[self release];
|
||||
self = [mutableDataMalloc alloc];
|
||||
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
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));
|
||||
bytes = 0;
|
||||
[self release];
|
||||
self = [mutableDataMalloc alloc];
|
||||
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithCapacity: bufferSize];
|
||||
}
|
||||
length = 0;
|
||||
|
|
|
@ -142,23 +142,21 @@ static Class NSMutableDictionary_concrete_class;
|
|||
|
||||
+ dictionary
|
||||
{
|
||||
return [[[self alloc] init]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithDictionary: (NSDictionary*)otherDictionary
|
||||
{
|
||||
return [[[self alloc] initWithDictionary: otherDictionary] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithDictionary: otherDictionary] autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithObjects: (id*)objects
|
||||
forKeys: (id*)keys
|
||||
count: (unsigned)count
|
||||
{
|
||||
return [[[self alloc] initWithObjects: objects
|
||||
forKeys: keys
|
||||
count: count]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects forKeys: keys count: count] autorelease];
|
||||
}
|
||||
|
||||
- (unsigned) hash
|
||||
|
@ -274,8 +272,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
}
|
||||
}
|
||||
NSAssert (argi % 2 == 0, NSInvalidArgumentException);
|
||||
d = [[[self alloc] initWithObjects: objects forKeys: keys
|
||||
count: num_pairs] autorelease];
|
||||
d = [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects forKeys: keys count: num_pairs] autorelease];
|
||||
OBJC_FREE(objects);
|
||||
OBJC_FREE(keys);
|
||||
return d;
|
||||
|
@ -286,14 +284,14 @@ static Class NSMutableDictionary_concrete_class;
|
|||
|
||||
+ dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys
|
||||
{
|
||||
return [[[self alloc] initWithObjects: objects forKeys: keys]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects forKeys: keys] autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithObject: (id)object forKey: (id)key
|
||||
{
|
||||
return [[[self alloc] initWithObjects: &object forKeys: &key count: 1]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: &object forKeys: &key count: 1] autorelease];
|
||||
}
|
||||
|
||||
/* Override superclass's designated initializer */
|
||||
|
@ -346,7 +344,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
{
|
||||
NSString *myString;
|
||||
|
||||
myString = [[NSString alloc] initWithContentsOfFile: path];
|
||||
myString = [[NSString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path];
|
||||
if (myString)
|
||||
{
|
||||
id result;
|
||||
|
@ -374,8 +373,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
|
||||
+ dictionaryWithContentsOfFile: (NSString *)path
|
||||
{
|
||||
return [[[self alloc] initWithContentsOfFile: path]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path] autorelease];
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: other
|
||||
|
@ -418,8 +417,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
NSAssert (k[i], NSInternalInconsistencyException);
|
||||
}
|
||||
NSAssert (![e nextObject], NSInternalInconsistencyException);
|
||||
return [[[NSArray alloc] initWithObjects: k count: c]
|
||||
autorelease];
|
||||
return [[[NSArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: k count: c] autorelease];
|
||||
}
|
||||
|
||||
- (NSArray*) allValues
|
||||
|
@ -434,8 +433,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
NSAssert (k[i], NSInternalInconsistencyException);
|
||||
}
|
||||
NSAssert (![e nextObject], NSInternalInconsistencyException);
|
||||
return [[[NSArray alloc] initWithObjects: k count: c]
|
||||
autorelease];
|
||||
return [[[NSArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: k count: c] autorelease];
|
||||
}
|
||||
|
||||
- (NSArray*) allKeysForObject: anObject
|
||||
|
@ -449,8 +448,8 @@ static Class NSMutableDictionary_concrete_class;
|
|||
a[c++] = k;
|
||||
if (c == 0)
|
||||
return nil;
|
||||
return [[[NSArray alloc] initWithObjects: a count: c]
|
||||
autorelease];
|
||||
return [[[NSArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: a count: c] autorelease];
|
||||
}
|
||||
|
||||
struct foo { NSDictionary *d; SEL s; IMP i; };
|
||||
|
@ -717,8 +716,8 @@ static NSString *indentStrings[] = {
|
|||
|
||||
+ dictionaryWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [[[self alloc] initWithCapacity: numItems]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: numItems] autorelease];
|
||||
}
|
||||
|
||||
/* Override superclass's designated initializer */
|
||||
|
|
|
@ -590,8 +590,8 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
|||
}
|
||||
*ptr++ = '"';
|
||||
*ptr = '\0';
|
||||
result = [[_fastCls._NSGCString alloc] initWithCStringNoCopy: buf
|
||||
length: length+2 fromZone: z];
|
||||
result = [[_fastCls._NSGCString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCStringNoCopy: buf length: length+2 fromZone: z];
|
||||
[output appendString: result];
|
||||
[result release];
|
||||
}
|
||||
|
|
|
@ -248,7 +248,8 @@
|
|||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
return [[[NSGCountedSetEnumerator alloc] initWithSet: self] autorelease];
|
||||
return [[[NSGCountedSetEnumerator allocWithZone: NSDefaultMallocZone()]
|
||||
initWithSet: self] autorelease];
|
||||
}
|
||||
|
||||
- (void) removeObject: (NSObject*)anObject
|
||||
|
|
|
@ -290,14 +290,14 @@ myEqual(id self, id other)
|
|||
|
||||
- (NSEnumerator*) keyEnumerator
|
||||
{
|
||||
return [[[NSGDictionaryKeyEnumerator alloc] initWithDictionary: self]
|
||||
autorelease];
|
||||
return [[[NSGDictionaryKeyEnumerator allocWithZone: NSDefaultMallocZone()]
|
||||
initWithDictionary: self] autorelease];
|
||||
}
|
||||
|
||||
- (NSEnumerator*) objectEnumerator
|
||||
{
|
||||
return [[[NSGDictionaryObjectEnumerator alloc] initWithDictionary: self]
|
||||
autorelease];
|
||||
return [[[NSGDictionaryObjectEnumerator allocWithZone: NSDefaultMallocZone()]
|
||||
initWithDictionary: self] autorelease];
|
||||
}
|
||||
|
||||
- (id) objectForKey: aKey
|
||||
|
|
|
@ -72,37 +72,42 @@ static Class NSMutableSet_concrete_class;
|
|||
|
||||
+ set
|
||||
{
|
||||
return [[[self alloc] init] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
|
||||
}
|
||||
|
||||
+ setWithObjects: (id*)objects
|
||||
count: (unsigned)count
|
||||
{
|
||||
return [[[self alloc] initWithObjects: objects count: count] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: objects count: count] autorelease];
|
||||
}
|
||||
|
||||
+ setWithArray: (NSArray*)objects
|
||||
{
|
||||
return [[[self alloc] initWithArray: objects] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithArray: objects] autorelease];
|
||||
}
|
||||
|
||||
+ setWithObject: anObject
|
||||
{
|
||||
return [[[self alloc] initWithObjects: &anObject count: 1] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: &anObject count: 1] autorelease];
|
||||
}
|
||||
|
||||
+ setWithObjects: firstObject, ...
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, firstObject);
|
||||
self = [[self alloc] initWithObjects: firstObject rest: ap];
|
||||
self = [[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: firstObject rest: ap];
|
||||
va_end(ap);
|
||||
return [self autorelease];
|
||||
}
|
||||
|
||||
+ setWithSet: (NSSet*)aSet
|
||||
{
|
||||
return [[[self alloc] initWithSet: aSet] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithSet: aSet] autorelease];
|
||||
}
|
||||
|
||||
+ allocWithZone: (NSZone*)z
|
||||
|
@ -277,7 +282,8 @@ static Class NSMutableSet_concrete_class;
|
|||
{
|
||||
k[i] = [e nextObject];
|
||||
}
|
||||
return [[[NSArray alloc] initWithObjects: k count: c] autorelease];
|
||||
return [[[NSArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithObjects: k count: c] autorelease];
|
||||
}
|
||||
|
||||
- (id) anyObject
|
||||
|
@ -427,7 +433,8 @@ static Class NSMutableSet_concrete_class;
|
|||
|
||||
+ (id) setWithCapacity: (unsigned)numItems
|
||||
{
|
||||
return [[[self alloc] initWithCapacity: numItems] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: numItems] autorelease];
|
||||
}
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)z
|
||||
|
|
|
@ -280,39 +280,39 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
+ (NSString*) string
|
||||
{
|
||||
return [[[self alloc] init] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()] init] autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithString: (NSString*)aString
|
||||
{
|
||||
return [[[self alloc] initWithString: aString] autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithString: aString] autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithCharacters: (const unichar*)chars
|
||||
length: (unsigned int)length
|
||||
{
|
||||
return [[[self alloc]
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharacters: chars length: length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithCString: (const char*) byteString
|
||||
{
|
||||
return [[[NSString_c_concrete_class alloc] initWithCString:byteString]
|
||||
autorelease];
|
||||
return [[[NSString_c_concrete_class allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCString: byteString] autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithCString: (const char*)byteString
|
||||
length: (unsigned int)length
|
||||
{
|
||||
return [[[NSString_c_concrete_class alloc]
|
||||
initWithCString:byteString length:length]
|
||||
autorelease];
|
||||
return [[[NSString_c_concrete_class allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCString: byteString length: length] autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithContentsOfFile: (NSString *)path
|
||||
{
|
||||
return [[[self alloc]
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithContentsOfFile: path] autorelease];
|
||||
}
|
||||
|
||||
|
@ -322,8 +322,11 @@ handle_printf_atsign (FILE *stream,
|
|||
id ret;
|
||||
|
||||
va_start(ap, format);
|
||||
ret = [[[self alloc] initWithFormat:format arguments:ap]
|
||||
autorelease];
|
||||
if (format == nil)
|
||||
ret = nil;
|
||||
else
|
||||
ret = [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithFormat: format arguments: ap] autorelease];
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
@ -331,9 +334,8 @@ handle_printf_atsign (FILE *stream,
|
|||
+ (NSString*) stringWithFormat: (NSString*)format
|
||||
arguments: (va_list)argList
|
||||
{
|
||||
return [[[self alloc]
|
||||
initWithFormat:format arguments:argList]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithFormat: format arguments: argList] autorelease];
|
||||
}
|
||||
|
||||
|
||||
|
@ -732,9 +734,8 @@ handle_printf_atsign (FILE *stream,
|
|||
z = fastZone(self);
|
||||
buf = NSZoneMalloc(z, sizeof(unichar)*aRange.length);
|
||||
[self getCharacters: buf range: aRange];
|
||||
ret = [[[self class] alloc] initWithCharactersNoCopy: buf
|
||||
length: aRange.length
|
||||
fromZone: z];
|
||||
ret = [[[self class] allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharactersNoCopy: buf length: aRange.length fromZone: z];
|
||||
return [ret autorelease];
|
||||
}
|
||||
|
||||
|
@ -1912,7 +1913,8 @@ else
|
|||
};
|
||||
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
|
||||
|
@ -1924,7 +1926,8 @@ else
|
|||
s = NSZoneMalloc(z, sizeof(unichar)*(len+1));
|
||||
for(count=0;count<len;count++)
|
||||
s[count]=uni_tolower([self characterAtIndex: count]);
|
||||
return [[[[self class] alloc] initWithCharactersNoCopy: s
|
||||
return [[[[self class] allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharactersNoCopy: s
|
||||
length: len
|
||||
fromZone: z] autorelease];
|
||||
}
|
||||
|
@ -1938,9 +1941,8 @@ else
|
|||
s = NSZoneMalloc(z, sizeof(unichar)*(len+1));
|
||||
for(count=0;count<len;count++)
|
||||
s[count]=uni_toupper([self characterAtIndex: count]);
|
||||
return [[[[self class] alloc] initWithCharactersNoCopy: s
|
||||
length: len
|
||||
fromZone: z] autorelease];
|
||||
return [[[[self class] allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharactersNoCopy: s length: len fromZone: z] autorelease];
|
||||
}
|
||||
|
||||
// Storing the String
|
||||
|
@ -2595,9 +2597,8 @@ else
|
|||
}
|
||||
*upoint = (unichar)0;
|
||||
|
||||
ret = [[[[self class] alloc] initWithCharactersNoCopy: u
|
||||
length: uslen(u)
|
||||
fromZone: z] autorelease];
|
||||
ret = [[[[self class] allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharactersNoCopy: u length: uslen(u) fromZone: z] autorelease];
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2663,11 +2664,14 @@ else
|
|||
NSArray *r;
|
||||
int i;
|
||||
|
||||
a = [[NSMutableArray alloc] initWithCapacity: [paths count]];
|
||||
for (i = 0; i < [paths count]; i++) {
|
||||
a = [[NSMutableArray allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: [paths count]];
|
||||
for (i = 0; i < [paths count]; i++)
|
||||
{
|
||||
NSString *s = [paths objectAtIndex: i];
|
||||
|
||||
while ([s isAbsolutePath]) {
|
||||
while ([s isAbsolutePath])
|
||||
{
|
||||
s = [s substringFromIndex: 1];
|
||||
}
|
||||
s = [self stringByAppendingPathComponent: s];
|
||||
|
@ -2913,8 +2917,8 @@ else
|
|||
|
||||
+ (NSMutableString*) stringWithCapacity: (unsigned)capacity
|
||||
{
|
||||
return [[[self alloc] initWithCapacity:capacity]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCapacity: capacity] autorelease];
|
||||
}
|
||||
|
||||
/* Inefficient. */
|
||||
|
@ -2922,22 +2926,22 @@ else
|
|||
length: (unsigned)length
|
||||
{
|
||||
id n;
|
||||
n = [[self alloc] initWithCharacters: characters length: length];
|
||||
n = [[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithCharacters: characters length: length];
|
||||
return [n autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithCString: (const char*)byteString
|
||||
{
|
||||
return [[[NSMutableString_c_concrete_class alloc]
|
||||
initWithCString:byteString]
|
||||
autorelease];
|
||||
return [[[NSMutableString_c_concrete_class allocWithZone:
|
||||
NSDefaultMallocZone()] initWithCString: byteString] autorelease];
|
||||
}
|
||||
|
||||
+ (NSString*) stringWithCString: (const char*)byteString
|
||||
length: (unsigned int)length
|
||||
{
|
||||
return [[[NSMutableString_c_concrete_class alloc]
|
||||
initWithCString:byteString length:length]
|
||||
return [[[NSMutableString_c_concrete_class allocWithZone:
|
||||
NSDefaultMallocZone()] initWithCString: byteString length: length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
|
@ -2976,7 +2980,8 @@ else
|
|||
va_list ap;
|
||||
id tmp;
|
||||
va_start(ap, format);
|
||||
tmp = [[NSString alloc] initWithFormat:format arguments:ap];
|
||||
tmp = [[NSString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithFormat: format arguments: ap];
|
||||
va_end(ap);
|
||||
[self appendString: tmp];
|
||||
[tmp release];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue