Performance of vector::size() : is it as fast as reading a variable?

后端 未结 7 1238
孤城傲影
孤城傲影 2020-12-30 20:38

I have do an extensive calculation on a big vector of integers. The vector size is not changed during the calculation. The size of the vector is frequently accessed by the c

7条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-30 20:51

    Always get a profile of your application before looking at this sort of micro optimization. Remember that even if it performs a subtraction, the compiler could still easily optimize it in many ways that would negate any performance loss.

提交回复
热议问题