mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-21 04:32:03 +00:00
Performance improvements.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4215 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
46bce46b35
commit
d54ee72b01
8 changed files with 196 additions and 178 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Thu May 6 21:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSUnarchiver.m: Don't retain/release unless necessary.
|
||||
* Source/NSUserDefaults.m: ditto
|
||||
* Source/NSNotification.m: ditto
|
||||
* Source/NSFileManager.m: ditto
|
||||
* Source/NSBundle.m: ditto
|
||||
* Source/NSRunLoop.m: ditto
|
||||
* Source/NSAutoreleasePool.m: Bugfix in dealloc - would leave count
|
||||
of retained objects set high - caused deallocs of nil objects.
|
||||
|
||||
Thu May 6 17:06:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSString.m: Minor optimisations - use ([-allocWithZone:])
|
||||
|
|
|
@ -153,7 +153,8 @@ static IMP initImp;
|
|||
struct autorelease_thread_vars *tv = ARP_THREAD_VARS;
|
||||
_parent = tv->current_pool;
|
||||
_child = nil;
|
||||
[tv->current_pool _setChildPool: self];
|
||||
if (_parent)
|
||||
[_parent _setChildPool: self];
|
||||
tv->current_pool = self;
|
||||
}
|
||||
|
||||
|
@ -225,6 +226,7 @@ static IMP initImp;
|
|||
{
|
||||
NSAutoreleasePool *pool = ARP_THREAD_VARS->current_pool;
|
||||
|
||||
NSAssert(anObj, NSInvalidArgumentException);
|
||||
if (pool)
|
||||
[pool addObject: anObj];
|
||||
else
|
||||
|
@ -242,6 +244,7 @@ static IMP initImp;
|
|||
|
||||
- (void) addObject: anObj
|
||||
{
|
||||
NSAssert(anObj, NSInvalidArgumentException);
|
||||
/* If the global, static variable AUTORELEASE_ENABLED is not set,
|
||||
do nothing, just return. */
|
||||
if (!autorelease_enabled)
|
||||
|
@ -342,8 +345,10 @@ static IMP initImp;
|
|||
@"to check for release errors."];
|
||||
#endif
|
||||
released->objects[i] = nil;
|
||||
NSAssert(anObject, NSInternalInconsistencyException);
|
||||
[anObject release];
|
||||
}
|
||||
released->count = 0;
|
||||
released = released->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,12 +481,18 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (_path)
|
||||
{
|
||||
NSMapRemove(_bundles, _path);
|
||||
RELEASE(_bundleClasses);
|
||||
RELEASE(_infoDict);
|
||||
RELEASE(_localizations);
|
||||
RELEASE(_path);
|
||||
}
|
||||
if (_bundleClasses)
|
||||
RELEASE(_bundleClasses);
|
||||
if (_infoDict)
|
||||
RELEASE(_infoDict);
|
||||
if (_localizations)
|
||||
RELEASE(_localizations);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
|
@ -1259,9 +1259,11 @@ static NSFileManager* defaultManager = nil;
|
|||
|
||||
RELEASE(pathStack);
|
||||
RELEASE(enumStack);
|
||||
RELEASE(currentFileName);
|
||||
RELEASE(currentFilePath);
|
||||
RELEASE(topPath);
|
||||
if (currentFileName)
|
||||
RELEASE(currentFileName);
|
||||
if (currentFilePath)
|
||||
RELEASE(currentFilePath);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
|
@ -33,17 +33,19 @@
|
|||
userInfo: info
|
||||
{
|
||||
[super init];
|
||||
_name = [name copy];
|
||||
_object = [object retain];
|
||||
_info = [info retain];
|
||||
_name = [name copyWithZone: NSDefaultMallocZone()];
|
||||
_object = (object != nil) ? RETAIN(object) : nil;
|
||||
_info = (info != nil) ? RETAIN(info) : nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_name release];
|
||||
[_object release];
|
||||
[_info release];
|
||||
RELEASE(_name);
|
||||
if (_object)
|
||||
RELEASE(_object);
|
||||
if (_info)
|
||||
RELEASE(_info);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -54,18 +56,14 @@
|
|||
object: object
|
||||
userInfo: info
|
||||
{
|
||||
return [[[self alloc] initWithName: name
|
||||
object: object
|
||||
userInfo: info]
|
||||
autorelease];
|
||||
return [[[self allocWithZone: NSDefaultMallocZone()] initWithName: name
|
||||
object: object userInfo: info] autorelease];
|
||||
}
|
||||
|
||||
+ notificationWithName: (NSString*)name
|
||||
object: object
|
||||
{
|
||||
return [self notificationWithName: name
|
||||
object: object
|
||||
userInfo: nil];
|
||||
return [self notificationWithName: name object: object userInfo: nil];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ static NSComparisonResult aSort(FastArrayItem i0, FastArrayItem i1)
|
|||
else if ([obj respondsToSelector: @selector(delegate)])
|
||||
{
|
||||
obj = [obj delegate];
|
||||
if ([obj respondsToSelector: @selector(limitDateForMode:)])
|
||||
if (obj != nil && [obj respondsToSelector: @selector(limitDateForMode:)])
|
||||
{
|
||||
NSDate *d = [obj limitDateForMode: mode];
|
||||
|
||||
|
@ -874,7 +874,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
else if ([obj respondsToSelector: @selector(delegate)])
|
||||
{
|
||||
obj = [obj delegate];
|
||||
if ([obj respondsToSelector:
|
||||
if (obj != nil && [obj respondsToSelector:
|
||||
@selector(timedOutEvent:type:forMode:)])
|
||||
{
|
||||
nxt = [obj timedOutEvent: min_watcher->data
|
||||
|
|
|
@ -227,21 +227,16 @@ static SEL dValSel = @selector(decodeValueOfObjCType:at:);
|
|||
}
|
||||
- (void) dealloc
|
||||
{
|
||||
[original release];
|
||||
RELEASE(original);
|
||||
if (name)
|
||||
{
|
||||
[name release];
|
||||
RELEASE(name);
|
||||
}
|
||||
NSDeallocateObject(self);
|
||||
}
|
||||
- (void) mapToClass: (Class)c withName: (NSString*)n
|
||||
{
|
||||
if (n != name)
|
||||
{
|
||||
[n retain];
|
||||
[name release];
|
||||
name = n;
|
||||
}
|
||||
ASSIGN(name, n);
|
||||
class = c;
|
||||
}
|
||||
@end
|
||||
|
@ -321,11 +316,11 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[unarchiver release];
|
||||
RELEASE(unarchiver);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[unarchiver release];
|
||||
RELEASE(unarchiver);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -343,8 +338,8 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[data release];
|
||||
[objDict release];
|
||||
RELEASE(data);
|
||||
RELEASE(objDict);
|
||||
if (clsMap)
|
||||
{
|
||||
NSZone *z = clsMap->zone;
|
||||
|
@ -514,7 +509,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
* order to give the appearance that it's actually a
|
||||
* new object.
|
||||
*/
|
||||
[obj retain];
|
||||
RETAIN(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -601,7 +596,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
classInfo = [NSUnarchiverObjectInfo newWithName: className];
|
||||
[classInfo mapToClass: c withName: className];
|
||||
[objDict setObject: classInfo forKey: className];
|
||||
[classInfo release];
|
||||
RELEASE(classInfo);
|
||||
}
|
||||
classInfo->version = cver;
|
||||
FastArrayAddItem(clsMap, (FastArrayItem)classInfo);
|
||||
|
@ -965,7 +960,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
d = [[NSData allocWithZone: zone] initWithBytesNoCopy: b
|
||||
length: l
|
||||
fromZone: zone];
|
||||
[d autorelease];
|
||||
AUTORELEASE(d);
|
||||
[self decodeArrayOfObjCType: @encode(unsigned char)
|
||||
count: l
|
||||
at: b];
|
||||
|
@ -1053,7 +1048,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
/*
|
||||
* A newly allocated object needs to be autoreleased.
|
||||
*/
|
||||
return [obj autorelease];
|
||||
return AUTORELEASE(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1103,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
{
|
||||
info = [NSUnarchiverClassInfo newWithName: nameInArchive];
|
||||
[clsDict setObject: info forKey: nameInArchive];
|
||||
[info release];
|
||||
RELEASE(info);
|
||||
}
|
||||
[info mapToClass: c withName: trueName];
|
||||
}
|
||||
|
@ -1146,7 +1141,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
{
|
||||
info = [NSUnarchiverObjectInfo newWithName: nameInArchive];
|
||||
[objDict setObject: info forKey: nameInArchive];
|
||||
[info release];
|
||||
RELEASE(info);
|
||||
}
|
||||
[info mapToClass: c withName: trueName];
|
||||
}
|
||||
|
@ -1208,8 +1203,8 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
{
|
||||
Class c;
|
||||
|
||||
[data release];
|
||||
data = [anObject retain];
|
||||
RELEASE(data);
|
||||
data = RETAIN(anObject);
|
||||
c = fastClass(data);
|
||||
if (src != self)
|
||||
{
|
||||
|
@ -1311,7 +1306,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
(*dValImp)(self, dValSel, @encode(id), (void*)&obj);
|
||||
if (obj)
|
||||
{
|
||||
[obj release];
|
||||
RELEASE(obj);
|
||||
}
|
||||
}
|
||||
[self decodeArrayOfObjCType: type count: count at: buf];
|
||||
|
@ -1335,7 +1330,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
(*dValImp)(self, dValSel, @encode(id), (void*)&obj);
|
||||
if (obj)
|
||||
{
|
||||
[obj release];
|
||||
RELEASE(obj);
|
||||
}
|
||||
}
|
||||
(*dValImp)(self, dValSel, type, buf);
|
||||
|
@ -1355,7 +1350,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
(*dValImp)(self, dValSel, @encode(id), (void*)&obj);
|
||||
if (obj)
|
||||
{
|
||||
[obj release];
|
||||
RELEASE(obj);
|
||||
}
|
||||
}
|
||||
(*dValImp)(self, dValSel, type, buf);
|
||||
|
@ -1374,7 +1369,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
|
|||
(*dValImp)(self, dValSel, @encode(id), (void*)&obj);
|
||||
if (obj)
|
||||
{
|
||||
[obj release];
|
||||
RELEASE(obj);
|
||||
}
|
||||
}
|
||||
(*dValImp)(self, dValSel, @encode(id), (void*)anObject);
|
||||
|
|
|
@ -235,6 +235,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
currLang = [[env componentsSeparatedByString: @";"] retain];
|
||||
}
|
||||
}
|
||||
if (currLang)
|
||||
[uL addObjectsFromArray: currLang];
|
||||
|
||||
// Check if "English" is includet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue