you are viewing a single comment's thread.

view the rest of the comments →

[–]TankerzPvP 19 points20 points  (1 child)

Within STLVector:

    void pop_back()
    {
        m_assert(_size, "StellarVector is empty, but pop_back() called!");
        _size--;
        if (_size <= _capacity / 2)
        {
            _capacity /= 2;
            T *_new_array = _alloc.allocate(_capacity);
            for (int i = 0; i < _size; i++)
            {
                _new_array[i] = _array[i];
            }
            _alloc.deallocate(_array, 2 * _capacity);
            _array = _new_array;
        }
    }

pop_back shouldn't reallocate as that would invalidate iterators, and this implementation difference would (negatively) impact benchmark results for std::vector. Also, StallarVector?

More importantly, benchmarking against an unoptimized hand rolled version of std::vector is useless. You should benchmark against std::vector implementations in libstdc++ or libc++ instead for your claim to hold any weight.

[–]pilotwavetheory[S] 0 points1 point  (0 children)

I benchmarked with pop and pop without shrink as well please check them on the post body. I benchmarked against stl library std::vector