1 hour ago · Tech · hide

“Looking-glass upon the wall, who is fastest of us all?” — A C++ string class would ask, paraphrasing Snow White. As you probably already know, there are quite a few different kinds of strings available in C++. I was curious to compare the performance of Microsoft Visual Studio C++ STL string implementation versus ATL CString versus a custom string pool allocator. Basically, the pool allocator maintains a singly-linked list of chunks, and string memory is carved from each chunk just increasing a string character pointer. When there isn’t enough memory available in the current chunk to serve the requested allocation, a new chunk is allocated. The new chunk is safely linked to the previous chunk list maintained by the allocator object, and the memory for the requested string is carved from this new chunk. At destruction time, the linked list of chunks is traversed to properly release all the allocated memory blocks. Custom pool allocator You can find the complete compilable C++…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town