This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid setting PL_cv_has_eval unnecessarily
authorFather Chrysostomos <sprout@cpan.org>
Wed, 8 Dec 2010 02:28:46 +0000 (18:28 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 8 Dec 2010 02:28:46 +0000 (18:28 -0800)
Quoting op.c:

/* /$x/ may cause an eval, since $x might be qr/(?{..})/  */

But the (?{..})’s compilation is only ever reached in the scope of
‘use re 'eval'’, so we can avoid setting PL_cv_has_eval (and the
slight overhead that entails) when that pragma is off.

op.c

diff --git a/op.c b/op.c
index 469a008..13462d1 100644 (file)
--- a/op.c
+++ b/op.c
@@ -3930,7 +3930,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
            rcop->op_targ = pad_alloc(rcop->op_type, SVs_PADTMP);
 
        /* /$x/ may cause an eval, since $x might be qr/(?{..})/  */
            rcop->op_targ = pad_alloc(rcop->op_type, SVs_PADTMP);
 
        /* /$x/ may cause an eval, since $x might be qr/(?{..})/  */
-       PL_cv_has_eval = 1;
+       if (PL_hints & HINT_RE_EVAL) PL_cv_has_eval = 1;
 
        /* establish postfix order */
        if (pm->op_pmflags & PMf_KEEP || !(PL_hints & HINT_RE_EVAL)) {
 
        /* establish postfix order */
        if (pm->op_pmflags & PMf_KEEP || !(PL_hints & HINT_RE_EVAL)) {