diff options
author | David Mitchell <davem@iabyn.com> | 2017-07-14 09:47:58 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-07-27 11:30:23 +0100 |
commit | 5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24 (patch) | |
tree | 84b31d4ecc75273fe4880cbdd1112490685aa2c5 /pp.c | |
parent | 7caeb7be934ab798a490d6205914121a6a935f01 (diff) | |
download | perl-5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24.tar.gz |
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.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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 */ } |