aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
authorMichal Nazarewicz2016-08-03 03:52:49 +0200
committerMichal Nazarewicz2016-09-09 03:07:15 +0200
commit0e7eb64076c17b3252249aa2a3ef340ce9f395bb (patch)
tree339f048596ba216d0ba15808a3121515853189b5 /src/regex.c
parentc579b28f6281c9cc0b711a012c30bf00036c60bf (diff)
downloademacs-0e7eb64076c17b3252249aa2a3ef340ce9f395bb.tar.gz
emacs-0e7eb64076c17b3252249aa2a3ef340ce9f395bb.zip
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.
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/regex.c b/src/regex.c
index 5f51b43e6c8..41c1d3f6106 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -2888,22 +2888,18 @@ regex_compile (const_re_char *pattern, size_t size,
2888 done until now. */ 2888 done until now. */
2889 SETUP_BUFFER_SYNTAX_TABLE (); 2889 SETUP_BUFFER_SYNTAX_TABLE ();
2890 2890
2891 for (ch = 0; ch < 256; ++ch) 2891 for (c = 0; c < 0x80; ++c)
2892 { 2892 if (re_iswctype (c, cc))
2893 c = RE_CHAR_TO_MULTIBYTE (ch); 2893 {
2894 if (! CHAR_BYTE8_P (c) 2894 SET_LIST_BIT (c);
2895 && re_iswctype (c, cc)) 2895 c1 = TRANSLATE (c);
2896 { 2896 if (c1 == c)
2897 SET_LIST_BIT (ch); 2897 continue;
2898 c1 = TRANSLATE (c); 2898 if (ASCII_CHAR_P (c1))
2899 if (c1 == c) 2899 SET_LIST_BIT (c1);
2900 continue; 2900 else if ((c1 = RE_CHAR_TO_UNIBYTE (c1)) >= 0)
2901 if (ASCII_CHAR_P (c1)) 2901 SET_LIST_BIT (c1);
2902 SET_LIST_BIT (c1); 2902 }
2903 else if ((c1 = RE_CHAR_TO_UNIBYTE (c1)) >= 0)
2904 SET_LIST_BIT (c1);
2905 }
2906 }
2907 SET_RANGE_TABLE_WORK_AREA_BIT 2903 SET_RANGE_TABLE_WORK_AREA_BIT
2908 (range_table_work, re_wctype_to_bit (cc)); 2904 (range_table_work, re_wctype_to_bit (cc));
2909#endif /* emacs */ 2905#endif /* emacs */