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

Posted by zoli2k on Stack Overflow See other posts from Stack Overflow or by zoli2k
Published on 2010-05-02T12:02:16Z Indexed on 2010/05/02 12:07 UTC
Read the original article Hit count: 122

Filed under:
|
|
|

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 code. What is faster in general: using the vector::size() function or using helper constant vectorSize storing the size of the vector? I know that compilers usually able to inline the size() function when setting the proper compiler flags, however, making a function inline is something that a compiler may do but can not be forced.

© Stack Overflow or respective owner

Related posts about gcc

Related posts about c++