From 388b5395b2f8a4832b85d3e4d15de48cb4466e2b Mon Sep 17 00:00:00 2001 From: divinity76 Date: Sun, 18 Jan 2026 21:34:40 +0100 Subject: [PATCH] fix: Further optimize Color to_lower_ascii one less branch, and it really shows on microbenchmarks: https://quick-bench.com/q/pxrI9X9kVtpApj4iIeYnolxgfz4 - 1.6 times faster than https://github.com/opentibiabr/otclient/pull/1490 - 7.2 times faster than the original pre-1490 tolower. --- src/framework/util/color.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/framework/util/color.cpp b/src/framework/util/color.cpp index f120ed0cb2..9b083f6d46 100644 --- a/src/framework/util/color.cpp +++ b/src/framework/util/color.cpp @@ -133,9 +133,8 @@ namespace { inline std::string to_lower_ascii(std::string_view s) { std::string out(s); - for (char &c : out) - if (c >= 'A' && c <= 'Z') - c |= 0x20; + for (char& c : out) + c += (c >= 'A' && c <= 'Z') ? 0x20 : 0; return out; }