зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1156886 - Optimize toLowerCase and toUpperCase on ASCII characters. r=luke
--HG-- extra : rebase_source : 6e715d90e59540dd36e30414a77ab2d7c303b7e5
This commit is contained in:
Родитель
84b9e85db2
Коммит
b385723d9d
|
@ -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 */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче