As of version 10.0.40219.1 SP1Rel std::vector::_Reserve() code goes like this:if (max_size() - _Count < _Size)_Xlen();else if ((_Size += _Count) <= capacity());elsereserve(_Grow_to(_Size));}Now capacity() <= max_size() at all times. Which means that if capacity() >= _Size + _Count (enough room) then automatically max_size() >= _Size + _Count. Which means that whenever that code is invoked when a vector already has room (that's quite often) the check max_size() >= _Size() + _Count is redundant._Reserve() should be redesigned like this:if (capacity() - _Size >= _Count);//enough room - do nothingelse if( (max_size() - _Size < _Count)_Xlen();else{ reserve(_Grow_to( _Size+_Count));}so that the check is done only if there's a need for reallocation in the first place.
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...