Faster ascii_tolower

This commit is contained in:
Vinnie Falco
2017-11-21 09:55:48 -08:00
parent 99bf3f5556
commit 639266fd64
2 changed files with 15 additions and 14 deletions

View File

@ -1,6 +1,7 @@
Version 146: Version 146:
* Fix some typos * Fix some typos
* Faster ascii_tolower
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -55,9 +55,8 @@ inline
char char
ascii_tolower(char c) ascii_tolower(char c)
{ {
if(c >= 'A' && c <= 'Z') return ((static_cast<unsigned>(c) - 65U) < 26) ?
c += 'a' - 'A'; c + 'a' - 'A' : c;
return c;
} }
template<class = void> template<class = void>
@ -77,17 +76,18 @@ iequals(
a = *p1++; a = *p1++;
b = *p2++; b = *p2++;
if(a != b) if(a != b)
goto slow; {
} // slow loop
return true; do
{
while(n--) if(ascii_tolower(a) != ascii_tolower(b))
{ return false;
slow: a = *p1++;
if(ascii_tolower(a) != ascii_tolower(b)) b = *p2++;
return false; }
a = *p1++; while(n--);
b = *p2++; return true;
}
} }
return true; return true;
} }