mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Performance enhancements and bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3117 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e1a308224d
commit
76f51c0cc3
2 changed files with 68 additions and 25 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Mon Oct 26 10:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
src/NSGCString.m: Implemented ([-copy]) and ([-copyWithZone:]) to
|
||||||
|
work without invoking any methods uing the runtime - much faster.
|
||||||
|
src/NSObject.m: Bugfix and performance improvement to the -perform...
|
||||||
|
methods. They previously threw an exception if the method referred
|
||||||
|
to by the selector was not implemented (when they should have tried
|
||||||
|
forwarding instead) rather than when passed a nul selector.
|
||||||
|
|
||||||
Sun Oct 25 08:00:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Sun Oct 25 08:00:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
src/NSObject.m: Cache implementation for adding object to autorelease
|
src/NSObject.m: Cache implementation for adding object to autorelease
|
||||||
|
|
|
@ -464,16 +464,23 @@ static BOOL double_release_check_enabled = NO;
|
||||||
return [[self class] conformsToProtocol:aProtocol];
|
return [[self class] conformsToProtocol:aProtocol];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (IMP) instanceMethodForSelector: (SEL)aSelector
|
- (IMP) instanceMethodForSelector: (SEL)aSelector
|
||||||
{
|
{
|
||||||
return method_get_imp(class_get_instance_method(self, aSelector));
|
/*
|
||||||
|
* Since 'self' is an class, get_imp() will get the instance method.
|
||||||
|
*/
|
||||||
|
return get_imp((Class)self, aSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IMP) methodForSelector: (SEL)aSelector
|
- (IMP) methodForSelector: (SEL)aSelector
|
||||||
{
|
{
|
||||||
return (method_get_imp(object_is_instance(self)
|
/*
|
||||||
?class_get_instance_method(self->isa, aSelector)
|
* If 'self' is an instance, fastClass() will get the class,
|
||||||
:class_get_class_method(self->isa, aSelector)));
|
* and get_imp() will get the instance method.
|
||||||
|
* If 'self' is a class, fastClass() will get the meta-class,
|
||||||
|
* and get_imp() will get the class method.
|
||||||
|
*/
|
||||||
|
return get_imp(fastClass(self), aSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector
|
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector
|
||||||
|
@ -671,12 +678,20 @@ static BOOL double_release_check_enabled = NO;
|
||||||
|
|
||||||
- performSelector: (SEL)aSelector
|
- performSelector: (SEL)aSelector
|
||||||
{
|
{
|
||||||
IMP msg = objc_msg_lookup(self, aSelector);
|
IMP msg;
|
||||||
|
|
||||||
|
if (aSelector == 0)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"nul selector passed to %s", sel_get_name(_cmd)];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = get_imp(fastClass(self), aSelector);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
{
|
{
|
||||||
[NSException
|
[NSException raise: NSGenericException
|
||||||
raise: NSGenericException
|
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
||||||
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
return (*msg)(self, aSelector);
|
return (*msg)(self, aSelector);
|
||||||
|
@ -684,27 +699,45 @@ static BOOL double_release_check_enabled = NO;
|
||||||
|
|
||||||
- performSelector: (SEL)aSelector withObject: anObject
|
- performSelector: (SEL)aSelector withObject: anObject
|
||||||
{
|
{
|
||||||
IMP msg = objc_msg_lookup(self, aSelector);
|
IMP msg;
|
||||||
if (!msg)
|
|
||||||
|
if (aSelector == 0)
|
||||||
{
|
{
|
||||||
[NSException
|
[NSException raise: NSInvalidArgumentException
|
||||||
raise: NSGenericException
|
format: @"nul selector passed to %s", sel_get_name(_cmd)];
|
||||||
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg = get_imp(fastClass(self), aSelector);
|
||||||
|
if (!msg)
|
||||||
|
{
|
||||||
|
[NSException raise: NSGenericException
|
||||||
|
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
return (*msg)(self, aSelector, anObject);
|
return (*msg)(self, aSelector, anObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
- performSelector: (SEL)aSelector withObject: object1 withObject: object2
|
- performSelector: (SEL)aSelector withObject: object1 withObject: object2
|
||||||
{
|
{
|
||||||
IMP msg = objc_msg_lookup(self, aSelector);
|
IMP msg;
|
||||||
if (!msg)
|
|
||||||
|
if (aSelector == 0)
|
||||||
{
|
{
|
||||||
[NSException
|
[NSException raise: NSInvalidArgumentException
|
||||||
raise: NSGenericException
|
format: @"nul selector passed to %s", sel_get_name(_cmd)];
|
||||||
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg = get_imp(fastClass(self), aSelector);
|
||||||
|
if (!msg)
|
||||||
|
{
|
||||||
|
[NSException raise: NSGenericException
|
||||||
|
format: @"invalid selector passed to %s", sel_get_name(_cmd)];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
return (*msg)(self, aSelector, object1, object2);
|
return (*msg)(self, aSelector, object1, object2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,9 +765,10 @@ static BOOL double_release_check_enabled = NO;
|
||||||
|
|
||||||
- (BOOL) respondsToSelector: (SEL)aSelector
|
- (BOOL) respondsToSelector: (SEL)aSelector
|
||||||
{
|
{
|
||||||
return ((object_is_instance(self)
|
if (fastIsInstance(self))
|
||||||
?class_get_instance_method(self->isa, aSelector)
|
return (class_get_instance_method(fastClass(self), aSelector)!=METHOD_NULL);
|
||||||
:class_get_class_method(self->isa, aSelector))!=METHOD_NULL);
|
else
|
||||||
|
return (class_get_class_method(fastClass(self), aSelector)!=METHOD_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
- retain
|
- retain
|
||||||
|
@ -863,7 +897,7 @@ static BOOL double_release_check_enabled = NO;
|
||||||
return objc_msg_sendv(self, aSel, argFrame);
|
return objc_msg_sendv(self, aSel, argFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (IMP)instanceMethodFor:(SEL)aSel
|
+ (IMP) instanceMethodFor:(SEL)aSel
|
||||||
{
|
{
|
||||||
return [self instanceMethodForSelector:aSel];
|
return [self instanceMethodForSelector:aSel];
|
||||||
}
|
}
|
||||||
|
@ -876,7 +910,7 @@ static BOOL double_release_check_enabled = NO;
|
||||||
: nil;
|
: nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IMP)methodFor:(SEL)aSel
|
- (IMP) methodFor:(SEL)aSel
|
||||||
{
|
{
|
||||||
return [self methodForSelector:aSel];
|
return [self methodForSelector:aSel];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue