Skip to content

Commit f189e5d

Browse files
committed
Don't generate useless range table entries for ASCII chars
In multibyte regexps, each ASCII char or range in a character alternative produces a nonsense range table entry in addition to the correct bits in the ASCII bitmap. Those entries do not match anything but waste space and time. * src/regex-emacs.c (regex_compile): Don't generate reversed intervals.
1 parent 9dccaf8 commit f189e5d

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/regex-emacs.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,17 +2113,20 @@ regex_compile (re_char *pattern, ptrdiff_t size,
21132113
if (CHAR_BYTE8_P (c1))
21142114
c = BYTE8_TO_CHAR (128);
21152115
}
2116-
if (CHAR_BYTE8_P (c))
2117-
{
2118-
c = CHAR_TO_BYTE8 (c);
2119-
c1 = CHAR_TO_BYTE8 (c1);
2120-
for (; c <= c1; c++)
2121-
SET_LIST_BIT (c);
2122-
}
2123-
else if (multibyte)
2124-
SETUP_MULTIBYTE_RANGE (range_table_work, c, c1);
2125-
else
2126-
SETUP_UNIBYTE_RANGE (range_table_work, c, c1);
2116+
if (c <= c1)
2117+
{
2118+
if (CHAR_BYTE8_P (c))
2119+
{
2120+
c = CHAR_TO_BYTE8 (c);
2121+
c1 = CHAR_TO_BYTE8 (c1);
2122+
for (; c <= c1; c++)
2123+
SET_LIST_BIT (c);
2124+
}
2125+
else if (multibyte)
2126+
SETUP_MULTIBYTE_RANGE (range_table_work, c, c1);
2127+
else
2128+
SETUP_UNIBYTE_RANGE (range_table_work, c, c1);
2129+
}
21272130
}
21282131
}
21292132

0 commit comments

Comments
 (0)