pp_print() optimise for void return

This function is often called in void context; don't push a result
in void context which will will only be immediately popped again by the
following nextstate or unstack op. On PERL_RC_STACK builds, this
also avoids ++ing and --ing the return value's ref count.

In unknown context it just assumes non-void, rather than incurring the
cost of determining the caller's context.
This commit is contained in:
David Mitchell 2023-12-16 18:20:50 +00:00
parent c7715606ca
commit 52d6284a2f

View File

@ -2179,7 +2179,8 @@ PP(pp_print)
just_say_no:
rpp_popfree_to_NN(ORIGMARK);
rpp_xpush_IMM(retval);
if ((PL_op->op_flags & OPf_WANT) != OPf_WANT_VOID)
rpp_xpush_IMM(retval);
return NORMAL;
}