Re: [Plib-devel] On First Looking Into Baker's SSG (with apologies to John Keats)
Brought to you by:
sjbaker
From: Bert D. <dri...@pl...> - 2004-08-10 00:21:00
|
On Mon, 9 Aug 2004, Fay John F Contr AAC/WMG wrote: > (7) The file "ssgBase.cxx" has a variable "next_unique_id" that starts at 1 > and is incremented every time a new "ssgBase" object is created. The > operation used for this is a postfix "++". I am told that a prefix "++" is > ever-so-slightly faster because you don't have to save the return value > before incrementing the variable. Do we want to initialize the variable to > 0 (on line 27) and increment it (on line 68) with a prefix "++"? I always learned that trying to save a single CPU tick is incompatible with writing in C++ :-) For what it's worth, any compiler worth its salt will know if the original value will eventually be discarded and not bother so save it in that case. I'd be tremendously surprised if either MSVC for i386 or GCC for i386 got this wrong. I have actually seen code breaking over such optimizations. A far better argument for making the change is to establish a common idiom for a project. Cheers, -- Bert -- Bert Driehuis -- dri...@pl... -- +31-20-3116119 If the only tool you've got is an axe, every problem looks like fun! |