This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Change lookup for dumping pattern
authorKarl Williamson <khw@cpan.org>
Mon, 30 Jan 2017 21:01:29 +0000 (14:01 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 1 Jun 2017 12:33:17 +0000 (06:33 -0600)
Instead of using a bunch of branches, use strchr() to see if a
character is a member of a class.  This is a common paradigm in the
parsers.

regcomp.c

index 54d641d..f9d56c1 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -119,8 +119,7 @@ typedef struct scan_frame {
 
 /* Certain characters are output as a sequence with the first being a
  * backslash. */
-#define isBACKSLASHED_PUNCT(c)                                              \
-                    ((c) == '-' || (c) == ']' || (c) == '\\' || (c) == '^')
+#define isBACKSLASHED_PUNCT(c)  strchr("-]\\^", c)
 
 
 struct RExC_state_t {