Skip to content

Commit

Permalink
Merge cc5f702 into b00088e
Browse files Browse the repository at this point in the history
  • Loading branch information
richardleach committed Aug 21, 2021
2 parents b00088e + cc5f702 commit ba2281e
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions pp.c
Expand Up @@ -5845,10 +5845,30 @@ PP(pp_unshift)

av_unshift(ary, SP - MARK);
PL_delaymagic = DM_DELAY;
while (MARK < SP) {
SV * const sv = newSVsv(*++MARK);
(void)av_store(ary, i++, sv);

if (!SvSMAGICAL(ary)) {
/* The av_unshift above means that many of the checks inside
* av_store are unnecessary. If ary does not have store magic
* then a simple direct assignment is possible here. */
while (MARK < SP) {
SV * const sv = newSVsv(*++MARK);
assert( !SvTIED_mg((const SV *)ary, PERL_MAGIC_tied) );
assert( i >= 0 );
assert( !SvREADONLY(ary) );
assert( AvREAL(ary) || !AvREIFY(ary) );
assert( i <= AvMAX(ary) );
assert( i <= AvFILLp(ary) );
assert( !AvREAL(ary) || AvARRAY(ary)[i] == NULL );
AvARRAY(ary)[i] = sv;
i++;
}
} else {
while (MARK < SP) {
SV * const sv = newSVsv(*++MARK);
(void)av_store(ary, i++, sv);
}
}

if (PL_delaymagic & DM_ARRAY_ISA)
mg_set(MUTABLE_SV(ary));
PL_delaymagic = old_delaymagic;
Expand Down

0 comments on commit ba2281e

Please sign in to comment.