Bug: huge difference in time of `erase` vector method
Opened this issue · 1 comments
nicolasgasco commented
I am getting a huge different in time between my implementation of vector::erase
and the std
one.
My implementation is already pretty lean:
iterator erase(iterator position)
{
this->_alloc.destroy(&(*position));
for (iterator it = position; it < (this->end() - 1); ++it)
this->_alloc.construct(&(*(it)), *(it + 1));
this->_alloc.destroy(this->_data + this->_size - 1);
this->_size--;
return position;
}
What seems suspicious to me is that I'm pratically getting the same times no matter how much I tweak my code.
Also, I'm not getting such a huge difference in my own tests:
What seems especially suspicious is std
time in your tester.
yeta1990 commented
Although I suffer the same problem with erase(value), I think it's not a bug, it depends on how we implement the end() method: https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.1/stl__vector_8h-source.html#l00350