Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
- Subject: Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
- From: glenn andreas <email@hidden>
- Date: Thu, 23 Dec 2004 08:58:48 -0600
On Dec 23, 2004, at 7:21 AM, Aurélien Hugelé wrote:
hi list !
i'm tuning my application and since a long time ago, i noticed that
using indexOfObjectIdenticalTo: is far (i mean something like 1000 x
faster on 20 000 items) faster that indexOfObject:
IMO indexOfObject is just Olog(n) because it needs full traversal of
the array if the searched object is the last one.
but indexOfObjectIdenticalTo: use probably the same algorithm except
that the equality test is faster (address equality instead of
(slower?) isEqual: message)
but i think the speed difference would not be so large. I suppose that
in fact, NSArray use an internal structure to link an object address
to its index in the array...
Am i totally wrong ? is it "normal" that a "==" test is 1000 times
faster than isEqual: ?
what's your opinion ?
That you should use Shark and sample your application and actually see
what it is doing.
(Though certainly == is one instruction and isEqual is perhaps hundreds
of instructions).
Glenn Andreas email@hidden
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden