It is not mentioned in the article that writing "inline" does not automatically make the function inline. It only gives C++ compiler a hint that it might be worth inlining. Compiler can inline function even if it has no inline keyword, and can not inline even when the function has the keyword, if it decides inlining would be inefficient.
Unusual speed boost: size matters
21–30 of 74 posts
Re: Unusual speed boost: size matters
#22Re: Unusual speed boost: size matters
#23> The second big drop is the result of removing features and cleaning code that came from the Chromium project.
In the graph, the second big drop is ~5% of the initial code size, removing the chromium code actually reduced binary size more than the inlining fixes did.
Re: Unusual speed boost: size matters
#24It is not mentioned in the article that writing "inline" does not automatically make the function inline. It only gives C++ compiler a hint that it might be worth inlining. Compiler can inline function even if it has no inline keyword, and can not inline even when the function has the keyword, if it decides inlining would be inefficient.
Re: Unusual speed boost: size matters
#25looking on example 1, I wonder why don't languages like C++ or D or Go just add a "pure" keyword for functions that don't modify the global environment or their arguments? this will help the optimizers a lot I imagine. and yeah, I get it that there still could be roundabout side-effects, it's not Haskell, but the compiler could just trust the programmer that he knows what he's doing when he sticks the "pure" keyword…
Re: Unusual speed boost: size matters
#26Or even better then double: inline void updateCachedWidth() { m_cachedWidth = computeWidth() * deviceScaleFactor(); } Ghee, was that line so hard to read ? No it's easier ! (Might have just been an example though.)
Re: Unusual speed boost: size matters
#27It is not mentioned in the article that writing "inline" does not automatically make the function inline. It only gives C++ compiler a hint that it might be worth inlining. Compiler can inline function even if it has no inline keyword, and can not inline even when the function has the keyword, if it decides inlining would be inefficient.
Why does that keyword even exist then?
Re: Unusual speed boost: size matters
#28I may have missed it, but were there any stats about the actual performance gains? It often mentioned binary size etc but nothing about the impact it had.
I'm all for removing old code, but if you're going to claim performance gains then why not measure those?
Re: Unusual speed boost: size matters
#29 * Try to be explicit { rather than implicit }
* Carefully consider inlining { large blocks of code }
* Do not use static initializers { for infrequency or trivialities }Re: Unusual speed boost: size matters
#30Earlier quoted context omitted.
Why does that keyword even exist then?
Because some compilers do make use of that hint in useful ways. They're just not required to, nor are they required to do so in any specific situation, much like the register and volatile keywords.