diff --git a/src/Limonp/LocalVector.hpp b/src/Limonp/LocalVector.hpp index 2016d41..a293d7f 100644 --- a/src/Limonp/LocalVector.hpp +++ b/src/Limonp/LocalVector.hpp @@ -9,6 +9,10 @@ namespace Limonp { using namespace std; + /* + * LocalVector : T must be primitive type (char , int, size_t), if T is struct or class, LocalVector may be dangerous.. + * LocalVector is simple and not well-tested. + */ const size_t LOCAL_VECTOR_BUFFER_SIZE = 16; template class LocalVector @@ -92,13 +96,11 @@ namespace Limonp } void push_back(const T& t) { - if(!full()) + if(_size == _capacity) { - _ptr[_size++] = t; - return ; + assert(_capacity); + reserve(_capacity * 2); } - assert(_capacity); - reserve(_capacity * 2); _ptr[_size ++ ] = t; } void reserve(size_t size) @@ -118,10 +120,6 @@ namespace Limonp free(old); } } - bool full() const - { - return size() == capacity(); - } bool empty() const { return 0 == size();