3 ms·
isn't that the definition of the small string optimization? This is how the dinkumware implementation of std::string has behaved for years. The basic form of
by pillbug88 15y ago
isn't that the definition of the small string optimization?
This is how the dinkumware implementation of std::string has behaved for years. The basic form of the structure is a buffer and a pointer. If the pointer is filled in, it points to a heap string and follows cow semantics. Otherwise, the buffer is used, accomplishing the small string optimization.
I suppose I should have elaborated more. It just feels like the OP is "discovering" the wheel.
- ComputerGuru 15y agoAbsolutely. Keep in mind that the OP is coming from a Ruby background and TFA targets people more familiar with high-level interpreted languages than with C/C++. BTW, I think though I cannot be sure that both the GCC and MSVC std::string implementations use this optimization in release mode, but I gotta dash and don't have time to verify this fact, so take it with a grain of salt, if you will.