Skip to content

Commit

Permalink
Perl_clear_defarray - revise ternary as per @hvds review
Browse files Browse the repository at this point in the history
  • Loading branch information
richardleach committed May 13, 2021
1 parent ff11f44 commit 6c77e12
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pp_hot.c
Expand Up @@ -4966,17 +4966,16 @@ PP(pp_leavesub)
void
Perl_clear_defarray(pTHX_ AV* av, bool abandon)
{
const SSize_t fill = AvFILLp(av);

PERL_ARGS_ASSERT_CLEAR_DEFARRAY;

if (LIKELY(!abandon && SvREFCNT(av) == 1 && !SvMAGICAL(av))) {
av_clear(av);
AvREIFY_only(av);
}
else {
const SSize_t size = AvFILLp(av) + 1;
/* fill can be -1. The ternary gives consistency with av_extend() */
AV *newav = newAV_alloc_xz(fill < 3 ? 4 : fill);
AV *newav = newAV_alloc_xz(size < 4 ? 4 : size);
AvREIFY_only(newav);
PAD_SVl(0) = MUTABLE_SV(newav);
SvREFCNT_dec_NN(av);
Expand Down

0 comments on commit 6c77e12

Please sign in to comment.