C++ Vector at/[] operator speed

后端 未结 9 1683
借酒劲吻你
借酒劲吻你 2021-01-02 16:19

In order to give functions the option to modify the vector I can\'t do

curr = myvec.at( i );
doThis( curr );
doThat( curr );
doStuffWith( curr );
         


        
9条回答
  •  滥情空心
    2021-01-02 17:06

    When performance is an issue, there is no substitute for profiling. The optimization capabilities of compilers change from version to version, and tiny, insignificant alterations to source code can dramatically change the resulting performace.

    No one can answer this question but yourself: Create a test harness, and throw several algorithms at it and see what you get.

    ps. if performance really is an issue, well, i got a factor 10 speed increase out of a png decoder by removing the vectors and replacing them with raw arrays. Again, this was for Visual Studio 6. I am not claiming that a raw array substitution will give you a factor 10 improvement, but it is something to try.

提交回复
热议问题