• 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: speed of alloc/init for NSNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speed of alloc/init for NSNumber


  • Subject: Re: speed of alloc/init for NSNumber
  • From: mmalcolm crawford <email@hidden>
  • Date: Sun, 18 Jan 2004 13:24:58 -0800

On Jan 18, 2004, at 12:54 PM, Chuck Soper wrote:

I have an NSTableView with about 400 rows and four columns. I manage the content with an array of dictionaries. Some key values I display in each of the columns. One of the dictionary keys contains a single floating point number that has to be updated frequently.

Are you able to be more specific about "frequently"? And in particular how frequently compared to how often the value needs to be displayed in the table view?

Since NSNumber doesn't have an mutable version, I have to release and alloc/init it every time I update the number. Should I use NSMutableData to avoid all the alloc/init messages to NSNumber to speed up my code?

The first questions should probably be, how slow is your code at the moment, and are you sure this is the bottleneck? If you put everything into an NSMutableData, presumably you'll incur additional overheads elsewhere...?

If you do decide it's worth using an int instead of an NSNumber, you might consider using a custom class to represent your data. In your table view data source method you can (still) use valueForKey: to get the int values -- they'll be automatically turned into NSNumbers for you...

mmalc
_______________________________________________
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.

  • Follow-Ups:
    • Re: speed of alloc/init for NSNumber
      • From: Chuck Soper <email@hidden>
References: 
 >speed of alloc/init for NSNumber (From: Chuck Soper <email@hidden>)

  • Prev by Date: Re: speed of alloc/init for NSNumber
  • Next by Date: Re: speed of alloc/init for NSNumber
  • Previous by thread: Re: speed of alloc/init for NSNumber
  • Next by thread: Re: speed of alloc/init for NSNumber
  • Index(es):
    • Date
    • Thread