I\'m trying to make a rope data structure. It\'s a type of binary tree, i.e. a recursive data structure.
The purpose of a rope is that splitting and concatenation sh
In practice, though, it involves a heap allocation for (almost?) every modification of the strings.
If you want to avoid frequent heap allocation performance issues, then I'd suggest using a memory pool for your class that allocates a chunk of memory, and only needs to request a new allocation from the OS when it's full, which should occur pretty infrequently. You can then optimize accesses to the memory pool for allocating small-block data-types like char
, etc.
Andrei Alexandrescu has a great example of a small-block memory allocator in his "Modern C++ Design" book.