Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

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

fatalme
初學者
1,287 檢視
a=b=c;
or
b=c;
a=b;
Thanks.
0 積分
4 回應
Ilnar
初學者
1,287 檢視

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

Dost__Conrad_W
初學者
1,287 檢視
The compiler will optimize them to the same code.
jimdempseyatthecove
榮譽貢獻者 III
1,287 檢視
Quoting conradca
The compiler will optimize them to the same code.

Excepting when b and a are volatile.

dwms
初學者
1,287 檢視
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;
回覆