improve allocation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14254 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-08-09 07:51:11 +00:00
parent 1cac195ffb
commit 035082da71

View file

@ -31,19 +31,25 @@
@implementation NSNotification @implementation NSNotification
static Class abstractClass = 0;
static Class concreteClass = 0; static Class concreteClass = 0;
@class GSNotification; @class GSNotification;
+ (NSNotification*) allocWithZone: (NSZone*)z + (NSNotification*) allocWithZone: (NSZone*)z
{ {
return (id)NSAllocateObject(concreteClass, 0, z); if (self == abstractClass)
{
return (id)NSAllocateObject(concreteClass, 0, z);
}
return (id)NSAllocateObject(self, 0, z);
} }
+ (void) initialize + (void) initialize
{ {
if (concreteClass == 0) if (concreteClass == 0)
{ {
abstractClass = [NSNotification class];
concreteClass = [GSNotification class]; concreteClass = [GSNotification class];
} }
} }
@ -95,7 +101,7 @@ static Class concreteClass = 0;
- (id) init - (id) init
{ {
if ([self class] == [NSNotification class]) if ([self class] == abstractClass)
{ {
NSZone *z = [self zone]; NSZone *z = [self zone];