commit 28862e2fb16e2770ef44dbf265d7f27f2350d4c1
parent 4cae73463d44b65f49b64298df4cc55f87ef47dc
Author: Andrew Laack <andrew@laack.co>
Date: Thu, 1 Oct 2026 16:08:18 -0500
Improve perf by 47%...
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/utils.cpp b/src/utils.cpp
@@ -192,6 +192,12 @@ int u8len(unsigned char c) {
}
int u8width(const std::string& s, std::size_t i, int len) {
+
+ unsigned char c = static_cast<unsigned char>(s[i]);
+ if (len == 1 && c < 0x80) {
+ return (c >= 0x20 && c != 0x7F) ? 1 : 0;
+ }
+
std::mbstate_t st {};
wchar_t wc;
if (std::mbrtowc(&wc, s.data() + i, len, &st) != (std::size_t)len) {