enh(Ascii): improve performance for toLower/toUpper #3462

This commit is contained in:
Aleksandar Fabijanic
2023-11-26 18:56:54 -06:00
parent 1f4d575465
commit cc67fb36ea
2 changed files with 54 additions and 14 deletions

View File

@@ -208,7 +208,7 @@ inline bool Ascii::isPrintable(int ch)
inline int Ascii::toLower(int ch)
{
if (isUpper(ch))
return ch + 32;
return ch | 0x20;
else
return ch;
}
@@ -217,7 +217,7 @@ inline int Ascii::toLower(int ch)
inline int Ascii::toUpper(int ch)
{
if (isLower(ch))
return ch - 32;
return ch & ~0x20;
else
return ch;
}