moya-lang / Allocator

Ultra fast C++11 allocator for STL containers.
BSD 2-Clause "Simplified" License
270 stars 25 forks source link

Vector??? #8

Closed shahramkom closed 5 years ago

shahramkom commented 5 years ago

Why the vector is not on this list???

moya-mmoczala commented 5 years ago

Because the vector is working on different principle. If you know the max number of elements for the vector, you can reserve required memory by using srd::vector::reserve() function.

yhyu13 commented 3 years ago

@moya-mmoczala I've tried to add a similar test case foe vector in measure.cpp and it actually failed at here, why is n has to be 1?

moya-mmoczala commented 2 years ago

Vector is a container that does not have list based implementation. Instead, it is like an array - a single and continuous block of memory. So, as in case of Moya Allocator, if you know the maximum size you will work with then you can pre-allocate a memory. In other words, vector already works similarly to Moya Allocator so there is no way to make it any faster.