From 0fd5eacbba20c136307374df51bc994313db0157 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 13 Nov 2013 05:52:00 -0800 Subject: [PATCH] op.c: Turn on read-only flag for folded constants They are marked PADTMP, which causes them to be copied in any contexts where readonliness makes a difference, so marking them as read-only does not change the behaviour. What it does is allow a future commit to implement string swiping for PADTMPs. --- op.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/op.c b/op.c index c2029a3..29eb745 100644 --- a/op.c +++ b/op.c @@ -3563,7 +3563,10 @@ S_fold_constants(pTHX_ OP *o) #endif assert(sv); if (type == OP_STRINGIFY) SvPADTMP_off(sv); - else if (!SvIMMORTAL(sv)) SvPADTMP_on(sv); + else if (!SvIMMORTAL(sv)) { + SvPADTMP_on(sv); + SvREADONLY_on(sv); + } if (type == OP_RV2GV) newop = newGVOP(OP_GV, 0, MUTABLE_GV(sv)); else @@ -3612,7 +3615,10 @@ S_gen_constant_list(pTHX_ OP *o) ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, (SV *)av); if (AvFILLp(av) != -1) for (svp = AvARRAY(av) + AvFILLp(av); svp >= AvARRAY(av); --svp) + { SvPADTMP_on(*svp); + SvREADONLY_on(*svp); + } #ifdef PERL_MAD op_getmad(curop,o,'O'); #else -- 2.7.4