std::vector reserve() and push_back() is faster than resize() and array index, why?

后端 未结 4 876
余生分开走
余生分开走 2020-12-01 00:59

I was doing a quick performance test on a block of code

void ConvertToFloat( const std::vector< short >& audioBlock, 
                     std::vec         


        
4条回答
  •  执念已碎
    2020-12-01 01:13

    Does resize initialize the newly allocated vector where reserve just allocates but does not construct?

    Yes.

提交回复
热议问题