• 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: Implementing fast enumeration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing fast enumeration


  • Subject: Re: Implementing fast enumeration
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 2 May 2008 18:12:48 -0700


On 2 May '08, at 12:18 PM, Ben wrote:

I have a C array where the elements within it can be converted into multiple objects. Say I have 5 objects. Do I provide them all in one go and return the total number? Or just one per call and return the number remaining?

Return as many as you can at once, for best performance. What makes this API fast is that it allows the caller to loop over lots of objects at once inline, without having to keep calling into the enumerator. In tight loops the overhead of the Obj-C method dispatch (or CoreFoundation function call) is the dominating factor.


If you can return large numbers of objects at once, the performance of fast-iteration becomes nearly as good as using a native C array. (I did some of the early prototyping of this, a few years ago; IIRC, at about 50 objects per call, the overhead became negligible.)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Implementing fast enumeration (From: Ben <email@hidden>)

  • Prev by Date: ANN: CDBStore, a lightweight persistent dictionary
  • Next by Date: Re: Loading a .nib?
  • Previous by thread: Implementing fast enumeration
  • Next by thread: Re: Implementing fast enumeration
  • Index(es):
    • Date
    • Thread