From 5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Fri, 14 Jul 2017 09:47:58 +0100 Subject: pp_length: use TARGi rather rather than sv_setiv() TARGi(i,1) is equivalent to sv_setiv_mg(TARG,i), except that it inlines some simple common cases. Also add a couple of test for length on an overloaded utf8 string. I don't think it was being tested for properly. --- pp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pp.c') diff --git a/pp.c b/pp.c index 4c5c38ba49..5c2288d9fd 100644 --- a/pp.c +++ b/pp.c @@ -3247,11 +3247,11 @@ PP(pp_length) if(svflags & SVs_GMG) mg_get(sv); if (SvOK(sv)) { + STRLEN len; if (!IN_BYTES) /* reread to avoid using an C auto/register */ - sv_setiv(TARG, (IV)sv_len_utf8_nomg(sv)); + len = sv_len_utf8_nomg(sv); else { - STRLEN len; /* unrolled SvPV_nomg_const(sv,len) */ if(SvPOK_nog(sv)){ simple_pv: @@ -3259,20 +3259,18 @@ PP(pp_length) } else { (void)sv_2pv_flags(sv, &len, 0|SV_CONST_RETURN); } - sv_setiv(TARG, (IV)(len)); } + TARGi((IV)(len), 1); } else { if (!SvPADTMP(TARG)) { sv_set_undef(TARG); + SvSETMAGIC(TARG); } else { /* TARG is on stack at this point and is overwriten by SETs. This branch is the odd one out, so put TARG by default on stack earlier to let local SP go out of liveness sooner */ SETs(&PL_sv_undef); - goto no_set_magic; } } - SvSETMAGIC(TARG); - no_set_magic: return NORMAL; /* no putback, SP didn't move in this opcode */ } -- cgit v1.2.1