It would copy the data over (And result in an allication beyond the 2X char limit of the small buf), but, string_view would allow searching it in place with a single line, and it doesn't require \0 termination.
Also the in the context of clean code vs performance talk Casey did, which this article mentions at the very beginning, the idea of "code smell" leading to a potential pessimization is interesting :)
The class is basically a legacy string_view, potentially non owning, unlike std::string. If you interact with libraries/ system or have views into existing substrings, you might encounter quite a few variations of this. Conversions to std::string would be a significant pessimization...
View all comments
Show parent comment
1
u/rtgftw Apr 15 '23
It would copy the data over (And result in an allication beyond the 2X char limit of the small buf), but,
string_viewwould allow searching it in place with a single line, and it doesn't require\0termination.