Re:Avoid character-by-character processing when performance ...
by jonstewart on Saturday July 25, 2020 @09:06AM
(#23948890)
STL is great! How’s the performance, though, compared with TFA’s optimistic and hybrid versions?
Re:Avoid character-by-character processing when performance ...
by cornstalks on Saturday July 25, 2020 @10:16AM
(#23949328)
And for a fair comparison, here's an imperative loop that's way cleaner than what TFA used:
bool is_ascii_branchy(std::string_view v) {
for (auto c : v) if (uint8_t(c) < 128) return false;
return true;
}
Re:Avoid character-by-character processing when performance ...
by im3w1l on Saturday July 25, 2020 @05:58AM
(#23947957)
So I guess this would be the best way to write it if you have a set of long strings most of which are non-ascii, and most such strings having a high proportion of non-ascii? Since then early exit will really help.
If anyone is interested, here is simpler version: