• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
      • From: Aurélien Hugelé <email@hidden>
References: 
 >Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ? (From: Aurélien Hugelé <email@hidden>)

  • Prev by Date: Re: Using atos -p to get symbolic name of address?
  • Next by Date: Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
  • Previous by thread: Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
  • Next by thread: Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
  • Index(es):
    • Date
    • Thread