From 8e1dd0a2ad889c79bba741c52cdd829ba2dd9863 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 25 Oct 2010 09:53:44 +0100 Subject: [PATCH] In FastCalc.xs, inline the macros CONSTANT_OBJ and RETURN_MORTAL_BOOL. With the previous commit, both are now only used in one place. No need to use sv_2mortal() on the reset of boolSV(), as both PL_sv_no and PL_sv_yes are immortals. [And special-cased within the implementation of sv_2mortal() - not only is it a no-op, it's a non-free no-op :-)] --- dist/Math-BigInt-FastCalc/FastCalc.xs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs index f4a4caa..d8a5445 100644 --- a/dist/Math-BigInt-FastCalc/FastCalc.xs +++ b/dist/Math-BigInt-FastCalc/FastCalc.xs @@ -34,14 +34,6 @@ PROTOTYPES: DISABLE ST(0) = sv_2mortal(newSViv(value)); \ XSRETURN(1); -#define RETURN_MORTAL_BOOL(temp, comp) \ - ST(0) = sv_2mortal(boolSV( SvIV(temp) == comp)); - -#define CONSTANT_OBJ(int) \ - RETVAL = newAV(); \ - sv_2mortal((SV*)RETVAL); \ - av_push (RETVAL, newSViv( int )); - void _set_XS_BASE(BASE, BASE_LEN) SV* BASE @@ -311,7 +303,9 @@ _zero(class) _two = 2 _ten = 10 CODE: - CONSTANT_OBJ(ix) + RETVAL = newAV(); + sv_2mortal((SV*)RETVAL); + av_push (RETVAL, newSViv( ix )); OUTPUT: RETVAL @@ -342,17 +336,19 @@ _is_zero(class, x) _is_ten = 10 INIT: AV* a; - SV* temp; CODE: a = (AV*)SvRV(x); /* ref to aray, don't check ref */ if ( av_len(a) != 0) { - ST(0) = &PL_sv_no; - XSRETURN(1); /* len != 1, can't be '0' */ + ST(0) = &PL_sv_no; /* len != 1, can't be '0' */ + } + else + { + SV *const temp = *av_fetch(a, 0, 0); /* fetch first element */ + ST(0) = boolSV(SvIV(temp) == ix); } - temp = *av_fetch(a, 0, 0); /* fetch first element */ - RETURN_MORTAL_BOOL(temp, ix); + XSRETURN(1); ############################################################################## -- 2.7.4