mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Optimize NSAutoreleasePool +new
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3275 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3088258e10
commit
fffedeff85
5 changed files with 18 additions and 6 deletions
|
@ -609,7 +609,7 @@ static Class NSMutableArray_concrete_class;
|
|||
unsigned indentBase;
|
||||
NSMutableString *iBaseString;
|
||||
NSMutableString *iSizeString;
|
||||
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
unsigned count = [self count];
|
||||
NSString *plists[count];
|
||||
unsigned i;
|
||||
|
|
|
@ -93,10 +93,16 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
|
|||
|
||||
@implementation NSAutoreleasePool
|
||||
|
||||
static IMP allocImp;
|
||||
static IMP initImp;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSAutoreleasePool class])
|
||||
; // Anything to put here?
|
||||
{
|
||||
allocImp = [self methodForSelector: @selector(allocWithZone:)];
|
||||
initImp = [self instanceMethodForSelector: @selector(init)];
|
||||
}
|
||||
}
|
||||
|
||||
+ allocWithZone: (NSZone*)zone
|
||||
|
@ -110,6 +116,12 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
|
|||
return NSAllocateObject (self, 0, zone);
|
||||
}
|
||||
|
||||
+ new
|
||||
{
|
||||
id arp = (*allocImp)(self, @selector(allocWithZone:), NSDefaultMallocZone());
|
||||
return (*initImp)(arp, @selector(init));
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
if (!_released_head)
|
||||
|
|
|
@ -529,7 +529,7 @@ compareIt(id o1, id o2, void* context)
|
|||
NSMutableString *result;
|
||||
int size;
|
||||
int i;
|
||||
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSArray *keysArray = [self allKeys];
|
||||
int numKeys = [keysArray count];
|
||||
NSString *plists[numKeys];
|
||||
|
@ -610,7 +610,7 @@ compareIt(id o1, id o2, void* context)
|
|||
NSMutableString *iBaseString;
|
||||
NSMutableString *iSizeString;
|
||||
int i;
|
||||
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSArray *keyArray = [self allKeys];
|
||||
NSMutableArray *theKeys = [NSMutableArray arrayWithArray: keyArray];
|
||||
int numKeys = [theKeys count];
|
||||
|
|
|
@ -448,7 +448,7 @@ static NSFileManager* defaultManager = nil;
|
|||
NSString *next;
|
||||
BOOL result;
|
||||
|
||||
arp = [[NSAutoreleasePool alloc] init];
|
||||
arp = [NSAutoreleasePool new];
|
||||
item = [contents objectAtIndex: i];
|
||||
next = [path stringByAppendingPathComponent: item];
|
||||
result = [self removeFileAtPath: next handler: handler];
|
||||
|
|
|
@ -116,7 +116,7 @@ NSString *NSPortTimeoutException
|
|||
* Also - bracket with retain/release pair to prevent recursion.
|
||||
*/
|
||||
[super retain];
|
||||
arp = [[NSAutoreleasePool alloc] init];
|
||||
arp = [NSAutoreleasePool new];
|
||||
[self invalidate];
|
||||
[arp release];
|
||||
[super release];
|
||||
|
|
Loading…
Reference in a new issue