The log parser you inherited along with the on-call rotation allocates a std::string per token. Logs run a terabyte a day; the profiler says half the CPU goes to malloc. The CFO is asking why the server bill grows faster than revenue. The answer is string_view: slice the lines without copying a single byte.
Split a string into tokens using std::string_view — each token must be a view into the original buffer, not a freshly allocated std::string. Return the non-empty substrings between delimiters.
std::vector<std::string_view> whose elements point into the input — copy no character datastd::string_view (no per-token std::string)std::string_view own? (Nothing — what does that imply for lifetimes?)string_view into a temporary a dangling-view bug?std::strings?Walk the text tracking the start of the current run; when you hit a delimiter (or the end) and the run is non-empty, emit text.substr(start, i - start).
std::string_view::substr returns another view into the same buffer — it allocates nothing.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.