summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-14 09:47:58 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:23 +0100
commit5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24 (patch)
tree84b31d4ecc75273fe4880cbdd1112490685aa2c5 /pp.c
parent7caeb7be934ab798a490d6205914121a6a935f01 (diff)
downloadperl-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.c10
1 files changed, 4 insertions, 6 deletions
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 */
}