Post increment and decrement

krzaq via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 23 02:06:09 PDT 2015


On Monday, 23 March 2015 at 08:20:59 UTC, Kagamin wrote:
> On Saturday, 21 March 2015 at 16:59:05 UTC, welkam wrote:
>> In C++ world always writing ++var can save some perf when 
>> using with overloaded operators.
>
> Do you have an example?

The compiler cannot optimize away calls to external functions 
(such as operator new, as is my experience) that it cannot 
inline/see fully (I may be not 100% correct here, but I'm pretty 
sure it's in the right ballpark).

Here's an example, compare foo() and bar() (note the -O3): 
http://goo.gl/H9tCaK


More information about the Digitalmars-d mailing list