• 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: NSMutableArray + NSEnumerator = No Memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray + NSEnumerator = No Memory


  • Subject: Re: NSMutableArray + NSEnumerator = No Memory
  • From: Bill Bumgarner <email@hidden>
  • Date: Sat, 22 Sep 2007 15:22:39 -0700

On Sep 22, 2007, at 1:20 PM, James Bucanek wrote:
Which is why I'm really surprised that -objectEnumerator would be duplicating the array. I can see why it would want to do that if it want to be thread safe or protect against modification, but in Cocoa that's documented as not being supported and known to be hazardous.

Ahh... I misunderstood. It isn't copying the array's contents, it is copying the array of references. Which, in this case, appears to be enough to push your app over the edge.


Yes -- it is being overly safe above and beyond the documentation. I would not be surprised to see said safety net go away in the future in light of better warnings or errors when doing unsafe operations.

(3) sounds fairly futile. NSArray and friends have been quite highly optimized over time. Certainly, there are likely more optimizations possible, but they are unlikely to be simple to implement. Unless you have a highly specific usage pattern for which a non-general algorithm will be a significant performance win, it is unlikely that re-engineering that which already exists in the Foundation is going to be much of a win.

Well, I do have a fairly specific/simple usage pattern. Once the array is built, just about the only thing I do with it is iterate over it in various ways. So it could be easily replaced with a static array allocated with malloc() or NSData.


In that case, go for it... No controllers or bindings or array-like operations (valueForKey: makeObjectsPerformSelector: (sp)) is a pretty simple use case.

-objectAtIndex: may likely be fast enough, though?

b.bum

_______________________________________________

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: 
 >Re: NSMutableArray + NSEnumerator = No Memory (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: NSMutableArray + NSEnumerator = No Memory
  • Next by Date: Re: NSMutableArray + NSEnumerator = No Memory
  • Previous by thread: Re: NSMutableArray + NSEnumerator = No Memory
  • Next by thread: Re: NSMutableArray + NSEnumerator = No Memory
  • Index(es):
    • Date
    • Thread