This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Rmv unnecessary branch
authorKarl Williamson <khw@cpan.org>
Wed, 13 Mar 2019 19:36:00 +0000 (13:36 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 13 Mar 2019 21:42:49 +0000 (15:42 -0600)
The function memchr() seems to get inlined so it is very fast, and it's
legal to call it with a 0 length, so let it figure out that it's zero.

regcomp.c

index b5903bf..f0adce9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13269,9 +13269,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                 char name = *RExC_parse;
                 char * endbrace = NULL;
                 RExC_parse += 2;
-                if (RExC_parse < RExC_end) {
-                    endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
-                }
+                endbrace = (char *) memchr(RExC_parse, '}', RExC_end - RExC_parse);
 
                 if (! endbrace) {
                     vFAIL2("Missing right brace on \\%c{}", name);