• 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: Repetitive Appending of Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repetitive Appending of Strings


  • Subject: Re: Repetitive Appending of Strings
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 12 Feb 2008 11:21:07 -0800


On 12 Feb '08, at 10:44 AM, John Stiles wrote:

Honestly I suspect the method call itself won't be that expensive, but parsing and executing a format string does take a lot of time.

I have run into exactly this as a real hot-spot in a particular app. (It was generating a hex string from a block of data; basically the same kind of thing.)


My solution was to build the output in an NSMutableData, adding one or two ASCII characters at a time using -appendBytes:length:, and then create an NSString from the data using the NSAsciiStringEncoding. This is pretty efficient, especially if you initialize the data object with sufficient capacity.

On the other hand, it would probably take more than 1000 digits for one instance of this to consume any user-detectable amount of time.

—Jens_______________________________________________

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: 
 >Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: glenn andreas <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)

  • Prev by Date: Re: @property problem
  • Next by Date: Re: finding memory leaks
  • Previous by thread: Re: Repetitive Appending of Strings
  • Next by thread: Re: Repetitive Appending of Strings
  • Index(es):
    • Date
    • Thread