• 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: The bug where terminal and xcode ran "different"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The bug where terminal and xcode ran "different"


  • Subject: Re: The bug where terminal and xcode ran "different"
  • From: Paul Walmsley <email@hidden>
  • Date: Sun, 11 Feb 2007 18:51:25 +0000



For the most part I'll be using stl classes. But what about for when you want to write the highest performance stuff? For example, can I assume that a vector stores it's data linearly in RAM? if so, I could use the vector to allocate the memory, and then just access it with a pointer. The best of both I'd say! Either that or make a class which does exactly the same thing.
STL's vector is *defined* to store its data as a contiguous array. It's intended to have the same behaviour as if you'd created a raw c++-style array. If you are using STL algorithms as they were designed to be used I would be very surprised if had any worse performance than raw pointer arithmetic -- one of the main idioms of forward iterators is that they work in a similar way to incrementing pointers (and under the hood the compiler may translate them to pretty much the same thing anyway). One problem I have with stl, is that it's not really "lowest common denominator". The nice thing about simple libraries is that they tend to be available everywhere.

Now that I think about it, I think that idea might be a bit silly. Maybe an idea to use STL even within high performance code? I suppose STL should be available everywhere Iw ant to go these days right?
Unless you're dealing with some very niche platform and a *really* out of date compiler I'd be amazed if you didn't always have access to a standards-compliant STL implementation.

As someone has already mentioned, this does sound a little like a case of premature optimisation. If you really think you're going to get a performance hit if you don't use pointer arithmetic then run it through a profiler first. Xcode has the great Shark utility which will tell you exactly where you're spending your time.

Don't underestimate though the performance improvements you can get from writing good STL code. I saw a great seminar by Scott Meyers a while ago where one of the conclusions was 'the guy who wrote the optimiser is probably smarter than you' :-)

Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: The bug where terminal and xcode ran "different"
      • From: "Theodore H. Smith" <email@hidden>
References: 
 >Re: The bug where terminal and xcode ran "different" (From: Rob Probin <email@hidden>)
 >Re: The bug where terminal and xcode ran "different" (From: John Daniel <email@hidden>)
 >Re: The bug where terminal and xcode ran "different" (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: The bug where terminal and xcode ran "different"
  • Next by Date: Re: The bug where terminal and xcode ran "different"
  • Previous by thread: Re: The bug where terminal and xcode ran "different"
  • Next by thread: Re: The bug where terminal and xcode ran "different"
  • Index(es):
    • Date
    • Thread