зеркало из https://github.com/mozilla/gecko-dev.git
Bug 412047: optimizing regexp upper/lower. r=crowder,a=blocking1.9
This commit is contained in:
Родитель
a366d6c626
Коммит
e5294ff020
|
@ -353,22 +353,33 @@ typedef struct REGlobalData {
|
||||||
* code point value is less than decimal 128, then return ch.
|
* code point value is less than decimal 128, then return ch.
|
||||||
* 6. Return cu.
|
* 6. Return cu.
|
||||||
*/
|
*/
|
||||||
static jschar
|
static uintN
|
||||||
upcase(jschar ch)
|
upcase(uintN ch)
|
||||||
{
|
{
|
||||||
jschar cu = JS_TOUPPER(ch);
|
uintN cu;
|
||||||
if (ch >= 128 && cu < 128)
|
|
||||||
|
JS_ASSERT((uintN) (jschar) ch == ch);
|
||||||
|
if (ch < 128) {
|
||||||
|
if (ch - (uintN) 'a' <= (uintN) ('z' - 'a'))
|
||||||
|
ch -= (uintN) ('a' - 'A');
|
||||||
return ch;
|
return ch;
|
||||||
return cu;
|
}
|
||||||
|
|
||||||
|
cu = JS_TOUPPER(ch);
|
||||||
|
return (cu < 128) ? ch : cu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jschar
|
static uintN
|
||||||
downcase(jschar ch)
|
downcase(uintN ch)
|
||||||
{
|
{
|
||||||
jschar cl = JS_TOLOWER(ch);
|
JS_ASSERT((uintN) (jschar) ch == ch);
|
||||||
if (cl >= 128 && ch < 128)
|
if (ch < 128) {
|
||||||
|
if (ch - (uintN) 'A' <= (uintN) ('Z' - 'A'))
|
||||||
|
ch += (uintN) ('a' - 'A');
|
||||||
return ch;
|
return ch;
|
||||||
return cl;
|
}
|
||||||
|
|
||||||
|
return JS_TOLOWER(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Construct and initialize an RENode, returning NULL for out-of-memory */
|
/* Construct and initialize an RENode, returning NULL for out-of-memory */
|
||||||
|
@ -944,7 +955,7 @@ CalculateBitmapSize(CompilerState *state, RENode *target, const jschar *src,
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
if (src < end && RE_IS_LETTER(*src)) {
|
if (src < end && RE_IS_LETTER(*src)) {
|
||||||
localMax = (jschar) (*src++ & 0x1F);
|
localMax = (uintN) (*src++) & 0x1F;
|
||||||
} else {
|
} else {
|
||||||
--src;
|
--src;
|
||||||
localMax = '\\';
|
localMax = '\\';
|
||||||
|
@ -1044,7 +1055,7 @@ lexHex:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (state->flags & JSREG_FOLD) {
|
if (state->flags & JSREG_FOLD) {
|
||||||
c = JS_MAX(upcase((jschar) localMax), downcase((jschar) localMax));
|
c = (jschar) JS_MAX(upcase(localMax), downcase(localMax));
|
||||||
if (c > localMax)
|
if (c > localMax)
|
||||||
localMax = c;
|
localMax = c;
|
||||||
}
|
}
|
||||||
|
@ -2220,12 +2231,12 @@ AddCharacterToCharSet(RECharSet *cs, jschar c)
|
||||||
|
|
||||||
/* Add a character range, c1 to c2 (inclusive) to the RECharSet */
|
/* Add a character range, c1 to c2 (inclusive) to the RECharSet */
|
||||||
static void
|
static void
|
||||||
AddCharacterRangeToCharSet(RECharSet *cs, jschar c1, jschar c2)
|
AddCharacterRangeToCharSet(RECharSet *cs, uintN c1, uintN c2)
|
||||||
{
|
{
|
||||||
uintN i;
|
uintN i;
|
||||||
|
|
||||||
uintN byteIndex1 = (uintN)(c1 >> 3);
|
uintN byteIndex1 = c1 >> 3;
|
||||||
uintN byteIndex2 = (uintN)(c2 >> 3);
|
uintN byteIndex2 = c2 >> 3;
|
||||||
|
|
||||||
JS_ASSERT((c2 <= cs->length) && (c1 <= c2));
|
JS_ASSERT((c2 <= cs->length) && (c1 <= c2));
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче