diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-25 09:53:44 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-25 09:53:44 +0100 |
commit | 8e1dd0a2ad889c79bba741c52cdd829ba2dd9863 (patch) | |
tree | 5145726a714a3ed869133c2e2da52d6a7d1afb28 | |
parent | 2d032f98e20bdaececd8548459379c3cf87746ec (diff) | |
download | perl-8e1dd0a2ad889c79bba741c52cdd829ba2dd9863.tar.gz |
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 :-)]
-rw-r--r-- | dist/Math-BigInt-FastCalc/FastCalc.xs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs index f4a4caaded..d8a5445089 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); ############################################################################## |