Custom C++ String Pool Allocator, including benchmark code to compare vs. STL strings.
by Giovanni Dicanio
Reusable code can be found in the StringPool.h
header.
This repo constains a VS2015 solution; anyway, I wrote the C++ code to be cross-platform (e.g. there are no dependencies from <Windows.h>
or other Windows-specific headers).
The basic idea of this custom string pool allocator is to allocate big chunks of memory, and then serve single string allocations carving memory from inside those blocks, with a simple fast pointer increase.
Moreover, the custom string class implemented to work with this allocator is very fast to sort as well, as it just contains a string pointer and a length data members, and its copy semantics is simple member-wise copy.