• 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: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 13 Feb 2008 00:54:00 +0100


Le 13 févr. 08 à 00:25, Adam P Jenkins a écrit :

Yeah, it was about 0.007 seconds without the reserve() call, but since I was doing the equivalent of reserve with the NSMutableData case, it seems more even to do the same with the vector<char> case.

As for clear(), I tried changing the code to use the swap trick you showed, and the timing results were the same. I don't understand why the vector[i]=ch example runs faster than the raw array access example. It must just be an artifact of some allocation and caching behavior. I'm fine with just calling them the same.

In any case it shows that for small methods where you don't actually need dynamic dispatch, C++'s inlining and non-virtual methods can yield much faster code than you can get with Objective-C classes.

Adam

The String way is slow due to the format parsing. For bench I think I will do this:


{
	UniChar uch = (i % 10) + '0';
	CFStringAppendCharacters((CFMutableStringRef)str, &uch, 1);
}


_______________________________________________

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


  • Follow-Ups:
    • Re: Repetitive Appending of Strings
      • From: Adam P Jenkins <email@hidden>
References: 
 >Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: "Michael Ash" <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Andrew Merenbach <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)
 >Re: Repetitive Appending of Strings (From: John Stiles <email@hidden>)
 >Re: Repetitive Appending of Strings (From: Adam P Jenkins <email@hidden>)

  • Prev by Date: Re: NSView -drawRect optimization
  • Next by Date: Re: IOKit.framework - The Destruction of my Project
  • Previous by thread: Re: Repetitive Appending of Strings
  • Next by thread: Re: Repetitive Appending of Strings
  • Index(es):
    • Date
    • Thread