On Sat, 30 Jun 2001, Brian Ingerson wrote:
> void
> add4 (...)
> PPCODE:
> {
> SV* sum = sv_newmortal();
> sv_setiv(sum, (IV)((int)SvIV(ST(0)) + (int)SvIV(ST(1))));
> ST(0) = sum;
> XSRETURN(1);
> }
That can get a little better (10% or so):
void
add4 (...)
PPCODE:
{
dXSTARG;
sv_setiv(TARG, (IV)((int)SvIV(ST(0)) + (int)SvIV(ST(1))));
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
That's a trick I picked up from Doug MacEachern. It saves a malloc by
using the same TARG register that opcodes use, as I understand it.
Of course, your point stands.
-sam