Use string views instead of passing std:wstring by const&
by Orochikaku on 3/30/2026, 2:31:57 AM
Comments
by: delta_p_delta_x
The zero-terminated string is by far C's worst design decision. It is single-handedly the cause for most performance, correctness, and security bugs, including many high-profile CVEs. I really do wish Pascal strings had caught on earlier and platform/kernel APIs used it, instead of an unqualified pointer-to-char that then hides an O(n) string traversal (by the platform) to find the null byte.<p>There are then questions about the length prefix, with a simple solution: make this a platform-specific detail and use the machine word. 16-bit platforms get strings of length ~2^16, 32 b platforms get 2^32 (which is a 4 GB-long string, which is more than 1000× as long as the entire Lord of the Rings trilogy), 64 b platforms get 2^64 (which is ~10^19).<p>Edit: I think a lot of commenters are focusing on the 'Pascalness' of Pascal strings, which I was using as an umbrella terminology for length-prefixed strings.
4/1/2026, 3:17:44 AM
by: quotemstr
It's usually the case that the more strident someone is in a blog post decrying innovation, the more wrong he is. The current article is no exception.<p>It's possible to define your own string_view workalike that has a c_str() and binds to whatever is stringlike can has a c_str. It's a few hundred lines of code. You don't have to live with the double indirection.
4/1/2026, 5:09:23 AM
by: breuwi
[Deleted, misread]
4/1/2026, 3:53:47 AM