mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Remove dead loop iterations in regex.c
RE_CHAR_TO_MULTIBYTE(c) yields c for ASCII characters and a byte8 character for c ≥ 0x80. Furthermore, CHAR_BYTE8_P(c) is true only for byte8 characters. This means that c = RE_CHAR_TO_MULTIBYTE (ch); if (! CHAR_BYTE8_P (c) && re_iswctype (c, cc)) is equivalent to: c = c; if (! false && re_iswctype (c, cc)) for 0 ⪬ c < 0x80, and c = BYTE8_TO_CHAR (c); if (! true && re_iswctype (c, cc)) for 0x80 ⪬ c < 0x100. In other words, the loop never executes for c ≥ 0x80 and RE_CHAR_TO_MULTIBYTE call is unnecessary for c < 0x80. * src/regex.c (regex_compile): Simplyfy a for loop by eliminating dead iterations and unnecessary macro calls.
This commit is contained in:
parent
c579b28f62
commit
0e7eb64076
1 changed files with 12 additions and 16 deletions
28
src/regex.c
28
src/regex.c
|
|
@ -2888,22 +2888,18 @@ regex_compile (const_re_char *pattern, size_t size,
|
|||
done until now. */
|
||||
SETUP_BUFFER_SYNTAX_TABLE ();
|
||||
|
||||
for (ch = 0; ch < 256; ++ch)
|
||||
{
|
||||
c = RE_CHAR_TO_MULTIBYTE (ch);
|
||||
if (! CHAR_BYTE8_P (c)
|
||||
&& re_iswctype (c, cc))
|
||||
{
|
||||
SET_LIST_BIT (ch);
|
||||
c1 = TRANSLATE (c);
|
||||
if (c1 == c)
|
||||
continue;
|
||||
if (ASCII_CHAR_P (c1))
|
||||
SET_LIST_BIT (c1);
|
||||
else if ((c1 = RE_CHAR_TO_UNIBYTE (c1)) >= 0)
|
||||
SET_LIST_BIT (c1);
|
||||
}
|
||||
}
|
||||
for (c = 0; c < 0x80; ++c)
|
||||
if (re_iswctype (c, cc))
|
||||
{
|
||||
SET_LIST_BIT (c);
|
||||
c1 = TRANSLATE (c);
|
||||
if (c1 == c)
|
||||
continue;
|
||||
if (ASCII_CHAR_P (c1))
|
||||
SET_LIST_BIT (c1);
|
||||
else if ((c1 = RE_CHAR_TO_UNIBYTE (c1)) >= 0)
|
||||
SET_LIST_BIT (c1);
|
||||
}
|
||||
SET_RANGE_TABLE_WORK_AREA_BIT
|
||||
(range_table_work, re_wctype_to_bit (cc));
|
||||
#endif /* emacs */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue