mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1156886 - Optimize toLowerCase and toUpperCase on ASCII characters. r=luke
This commit is contained in:
parent
d50a6635d4
commit
0f0dffb24e
@ -603,7 +603,7 @@ ToLowerCase(JSContext* cx, JSLinearString* str)
|
||||
size_t i = 0;
|
||||
for (; i < length; i++) {
|
||||
char16_t c = chars[i];
|
||||
if (unicode::ToLowerCase(c) != c)
|
||||
if (unicode::CanLowerCase(c))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -722,7 +722,7 @@ ToUpperCase(JSContext* cx, JSLinearString* str)
|
||||
size_t i = 0;
|
||||
for (; i < length; i++) {
|
||||
char16_t c = chars[i];
|
||||
if (unicode::ToUpperCase(c) != c)
|
||||
if (unicode::CanUpperCase(c))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,12 @@ IsSpaceOrBOM2(char16_t ch)
|
||||
inline char16_t
|
||||
ToUpperCase(char16_t ch)
|
||||
{
|
||||
if (ch < 128) {
|
||||
if (ch >= 'a' && ch <= 'z')
|
||||
return ch - ('a' - 'A');
|
||||
return ch;
|
||||
}
|
||||
|
||||
const CharacterInfo& info = CharInfo(ch);
|
||||
|
||||
return uint16_t(ch) + info.upperCase;
|
||||
@ -199,11 +205,35 @@ ToUpperCase(char16_t ch)
|
||||
inline char16_t
|
||||
ToLowerCase(char16_t ch)
|
||||
{
|
||||
if (ch < 128) {
|
||||
if (ch >= 'A' && ch <= 'Z')
|
||||
return ch + ('a' - 'A');
|
||||
return ch;
|
||||
}
|
||||
|
||||
const CharacterInfo& info = CharInfo(ch);
|
||||
|
||||
return uint16_t(ch) + info.lowerCase;
|
||||
}
|
||||
|
||||
// Returns true iff ToUpperCase(ch) != ch.
|
||||
inline bool
|
||||
CanUpperCase(char16_t ch)
|
||||
{
|
||||
if (ch < 128)
|
||||
return ch >= 'a' && ch <= 'z';
|
||||
return CharInfo(ch).upperCase != 0;
|
||||
}
|
||||
|
||||
// Returns true iff ToLowerCase(ch) != ch.
|
||||
inline bool
|
||||
CanLowerCase(char16_t ch)
|
||||
{
|
||||
if (ch < 128)
|
||||
return ch >= 'A' && ch <= 'Z';
|
||||
return CharInfo(ch).lowerCase != 0;
|
||||
}
|
||||
|
||||
} /* namespace unicode */
|
||||
} /* namespace js */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user