C++: Structs slower to access than basic variables?

后端 未结 9 2424
被撕碎了的回忆
被撕碎了的回忆 2021-02-13 03:45

I found some code that had \"optimization\" like this:

void somefunc(SomeStruct param){
    float x = param.x; // param.x and x are both floats. supposedly this          


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 04:16

    Compiler may make faster code to copy float-to-float. But when x will used it will be converted to internal FPU representation.

提交回复
热议问题