This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: Replace loop by memchr()
authorKarl Williamson <khw@cpan.org>
Wed, 27 Dec 2017 01:25:26 +0000 (18:25 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 30 Jan 2018 18:38:12 +0000 (11:38 -0700)
This can be called on a potentially long string.

regexec.c

index 5a1c5ef..ac8b15e 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -9003,8 +9003,10 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
                hardcount++;
            }
        } else {
-           while (scan < loceol && *scan != '\n')
-               scan++;
+            scan = (char *) memchr(scan, '\n', loceol - scan);
+            if (! scan) {
+                scan = loceol;
+            }
        }
        break;
     case SANY: