diff options
| author | Stefan Boberg <[email protected]> | 2021-10-19 13:29:46 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-19 13:29:46 +0200 |
| commit | 48970cf67bfd96e07fb036dd5467763c5c2ac20d (patch) | |
| tree | 067481d4ea960d00af9cbd2cd7f2aa8e5efe1d75 /zencore/include | |
| parent | iobuffer: added templated Data() to make typed data access easier (diff) | |
| download | zen-48970cf67bfd96e07fb036dd5467763c5c2ac20d.tar.xz zen-48970cf67bfd96e07fb036dd5467763c5c2ac20d.zip | |
string: Fixed ToLower logic (needs to use unsigned arithmetic)
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/string.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index a94e063a4..630341056 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -632,7 +632,7 @@ HashStringAsLowerDjb2(const std::string_view& InString) { uint32_t HashValue = 5381; - for (int CurChar : InString) + for (uint8_t CurChar : InString) { CurChar -= ((CurChar - 'A') <= ('Z' - 'A')) * ('A' - 'a'); // this should be compiled into branchless logic HashValue = HashValue * 33 + CurChar; @@ -650,7 +650,7 @@ ToLower(const std::string_view& InString) for (char& CurChar : Out) { - CurChar -= ((CurChar - 'A') <= ('Z' - 'A')) * ('A' - 'a'); // this should be compiled into branchless logic + CurChar -= (uint8_t(CurChar - 'A') <= ('Z' - 'A')) * ('A' - 'a'); // this should be compiled into branchless logic } return Out; |