C++ performance myths debunked

Mark Charsley mark.charsley at REMOVE_THIS.radioscape.com
Mon Aug 12 06:32:00 EDT 2002


In article <3d4acdcc.18746140 at news.t-online.de>, gerson.kurz at t-online.de 
(Gerson Kurz) wrote:

> Download the libraries from over at www.boost.org. Compile a sample
> program (with VC6), get 31 warnings like this (I'm not making this up,
> and yes, it is *one* single warning):

<SNIP>

> So much for C++ syntax.

It's more to do with MS's compiler than C++.

<C++ boost example snipped>

> Now try the same thing with strtok. It sure doesn't look so pretty:

Not a fair comparison. "strtok" is up there with "goto" on C/C++ 
programmers' "DANGER!" list. Unix man pages for it pretty much tell you 
not to use it, and MS's help file says that it

"uses a static variable for parsing the string into tokens. If multiple or 
simultaneous calls are made to the same function, a high potential for 
data corruption and inaccurate results exists. Therefore, do not attempt 
to call the same function simultaneously for different strings and be 
aware of calling one of these function from within a loop where another 
routine may be called that uses the same function.  However, calling this 
function simultaneously from multiple threads does not have undesirable 
effects."

I'd expect that the boost library is safer and thus expect it to be 
slower.


-- 

Mark - personal opinion only, could well be wrong, not representing 
company, don't sue us etc. etc.



More information about the Python-list mailing list