As of version 10.0.40219.1 SP1Rel std::vector::_Insert() code goes like this:if (_Count == 0);else if (max_size() - size() < _Count)_Xlen(); // result too longelse if (capacity() < size() + _Count){ // not enough room, reallocate //skipped}else{ // new stuff fits, append and rotate into place//skipped}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._Insert() should be redesigned like this:if (_Count == 0);else if (capacity() - size() < _Count){ if (max_size() - size() < _Count) _Xlen(); // result too long // not enough room, reallocate //skipped}else{ // new stuff fits, append and rotate into place//skipped}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...