Re: NSButton question
Re: NSButton question
- Subject: Re: NSButton question
- From: Ondra Cada <email@hidden>
- Date: Sat, 10 Aug 2002 14:23:20 +0200
On Saturday, August 10, 2002, at 10:15 , Simon Stapleton wrote:
Another side note: In Objective-C, we have no method overloading. Thus,
-isEqual: takes (id) as its parameter type, and must, in effect, route
the query to a more specialised routine depending on the types of the
compared objects. Those classes in Foundation requiring specialist
handling of -isEqual: (Strings, Arrays, etc) have specialist handlers -
-isEqualToString:, -isEqualToArray: etc, which are faster to use when you
know the types you're comparing.
It's slightly different. Right, isEqual is somewhat slower than
isEqualToString et comp, but the reason is *not* in "routing to a more
specialised routine". The sole difference is in the implementation --
isEqual checks explicitly for a proper class:
@implementation NSString ... // roughly, the actual implementation would
differ
...
-(BOOL)isEqual:o {
if (![o isKindOfClass:[NSString class]]) return NO; // THIS is what
makes it slower
return _someInternalTestOfEquality(self,o);
}
-(BOOL)isEqualToString:(NSString*)s {
return _someInternalTestOfEquality(self,o);
}
The dispatch is just as quick in both cases though.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.