C++ inlining of references (original) (raw)

Andrew Haley aph at redhat.com
Tue Mar 21 10:15:00 UTC 2017


On 21/03/17 09:25, Ioi Lam wrote:

Because the common header modifies 2 variables, there's no easy way to pass them back easily. So I pass them as references to the inline function.

Can I expect modern C++ compilers to always generate equally optimal code for the before/after cases?

Yes. Note that there is unlikely to be any advantage to a reference over taking the address of a variable, because they get lowered to the same thing anyway. Use whatever is easiest for people to read.

Andrew.



More information about the hotspot-dev mailing list