This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
It seems crazy for Perl_yylex() to individually shift each element off
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index 7587df1..b275c6a 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3611,12 +3611,13 @@ Perl_yylex(pTHX)
                }
            } else
                sv_setpvs(PL_linestr,"");
-           if (PL_preambleav){
-               while(AvFILLp(PL_preambleav) >= 0) {
-                   SV *tmpsv = av_shift(PL_preambleav);
-                   sv_catsv(PL_linestr, tmpsv);
+           if (PL_preambleav) {
+               SV **svp = AvARRAY(PL_preambleav);
+               SV **const end = svp + AvFILLp(PL_preambleav);
+               while(svp <= end) {
+                   sv_catsv(PL_linestr, *svp);
+                   ++svp;
                    sv_catpvs(PL_linestr, ";");
-                   sv_free(tmpsv);
                }
                sv_free((SV*)PL_preambleav);
                PL_preambleav = NULL;