summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorRuslan Zakirov <ruz@bestpractical.com>2012-10-17 20:04:58 +0400
committerFather Chrysostomos <sprout@cpan.org>2012-12-11 08:59:41 -0800
commit88e2091baeacd9a40eab4dac8601e88b3797e385 (patch)
treee33f6bc9e99a9056dcfe31333b85e3fe358dcf94 /pp_hot.c
parent1c4ea38437d309ec547e78e6f14940e799920be3 (diff)
downloadperl-88e2091baeacd9a40eab4dac8601e88b3797e385.tar.gz
don't create a copy of keys if it's not LVALUE context
Making another copy slows things down. We can avoid it if aassign is not expected to return LVALUEs.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index cd036dd1ae..76a9e43b20 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -992,9 +992,12 @@ PP(pp_aassign)
HV *hash;
I32 i;
int magic;
+ U32 lval = 0;
PL_delaymagic = DM_DELAY; /* catch simultaneous items */
gimme = GIMME_V;
+ if (gimme == G_ARRAY)
+ lval = PL_op->op_flags & OPf_MOD || LVRET;
/* If there's a common identifier on both sides we have to take
* special care that assigning the identifier on the left doesn't
@@ -1093,7 +1096,7 @@ PP(pp_aassign)
while (relem < lastrelem+odd) { /* gobble up all the rest */
HE *didstore;
assert(*relem);
- sv = gimme == G_ARRAY ? sv_mortalcopy(*relem) : *relem;
+ sv = lval ? sv_mortalcopy(*relem) : *relem;
relem++;
assert(*relem);
tmpstr = sv_mortalcopy( *relem++ ); /* value */