a=b=c; or b=c; a=b; which has higher time efficiency?

a=b=c; or b=c; a=b; which has higher time efficiency?

a=b=c;orb=c;a=b;Thanks.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Ilnar's picture

both constructions are equal, first one is just shorter syntacs of the second one

____________________ Борханов Ильнар

The compiler will optimize them to the same code.

jimdempseyatthecove's picture

Quoting conradcaThe compiler will optimize them to the same code.

Excepting when b and a are volatile.

www.quickthreadprogramming.com

An interesting exercise would be writing the code to do both and then reviewing the assembly generated by the compiler.Assuming this is not a complex data type, don't forget:a=c;b=c;

Login to leave a comment.