diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-25 09:24:06 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-25 09:26:23 +0100 |
commit | 2d032f98e20bdaececd8548459379c3cf87746ec (patch) | |
tree | dacbbf89721bd12f671d83ac66420339d249bac5 /dist/Math-BigInt-FastCalc | |
parent | 251c9b20f5a22a32411b6c61f432b8b68a43eb29 (diff) | |
download | perl-2d032f98e20bdaececd8548459379c3cf87746ec.tar.gz |
Reduce repetition in FastCalc.xs by using ALIASes.
_one, _two and _ten are aliases to _zero
_is_odd is an alias of _is_even
_is_one, _is_two, _is_ten are aliases of _is_zero
On this system this reduces the object code size by about 4.5K (about 20%).
Diffstat (limited to 'dist/Math-BigInt-FastCalc')
-rw-r--r-- | dist/Math-BigInt-FastCalc/FastCalc.pm | 2 | ||||
-rw-r--r-- | dist/Math-BigInt-FastCalc/FastCalc.xs | 114 |
2 files changed, 14 insertions, 102 deletions
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.pm b/dist/Math-BigInt-FastCalc/FastCalc.pm index ada0ba3a0a..03af519e08 100644 --- a/dist/Math-BigInt-FastCalc/FastCalc.pm +++ b/dist/Math-BigInt-FastCalc/FastCalc.pm @@ -11,7 +11,7 @@ use vars qw/@ISA $VERSION $BASE $BASE_LEN/; @ISA = qw(DynaLoader); -$VERSION = '0.22'; +$VERSION = '0.23'; bootstrap Math::BigInt::FastCalc $VERSION; diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs index 6dbe958645..f4a4caaded 100644 --- a/dist/Math-BigInt-FastCalc/FastCalc.xs +++ b/dist/Math-BigInt-FastCalc/FastCalc.xs @@ -306,35 +306,12 @@ _num(class,x) AV * _zero(class) + ALIAS: + _one = 1 + _two = 2 + _ten = 10 CODE: - CONSTANT_OBJ(0) - OUTPUT: - RETVAL - -############################################################################## - -AV * -_one(class) - CODE: - CONSTANT_OBJ(1) - OUTPUT: - RETVAL - -############################################################################## - -AV * -_two(class) - CODE: - CONSTANT_OBJ(2) - OUTPUT: - RETVAL - -############################################################################## - -AV * -_ten(class) - CODE: - CONSTANT_OBJ(10) + CONSTANT_OBJ(ix) OUTPUT: RETVAL @@ -343,6 +320,8 @@ _ten(class) void _is_even(class, x) SV* x + ALIAS: + _is_odd = 1 INIT: AV* a; SV* temp; @@ -350,84 +329,17 @@ _is_even(class, x) CODE: a = (AV*)SvRV(x); /* ref to aray, don't check ref */ temp = *av_fetch(a, 0, 0); /* fetch first element */ - ST(0) = sv_2mortal(boolSV((SvIV(temp) & 1) == 0)); - -############################################################################## - -void -_is_odd(class, x) - SV* x - INIT: - AV* a; - SV* temp; - - CODE: - a = (AV*)SvRV(x); /* ref to aray, don't check ref */ - temp = *av_fetch(a, 0, 0); /* fetch first element */ - ST(0) = sv_2mortal(boolSV((SvIV(temp) & 1) != 0)); - -############################################################################## - -void -_is_one(class, x) - SV* x - 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 '1' */ - } - temp = *av_fetch(a, 0, 0); /* fetch first element */ - RETURN_MORTAL_BOOL(temp, 1); - -############################################################################## - -void -_is_two(class, x) - SV* x - 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 '2' */ - } - temp = *av_fetch(a, 0, 0); /* fetch first element */ - RETURN_MORTAL_BOOL(temp, 2); - -############################################################################## - -void -_is_ten(class, x) - SV* x - 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 '10' */ - } - temp = *av_fetch(a, 0, 0); /* fetch first element */ - RETURN_MORTAL_BOOL(temp, 10); + ST(0) = sv_2mortal(boolSV((SvIV(temp) & 1) == ix)); ############################################################################## void _is_zero(class, x) SV* x + ALIAS: + _is_one = 1 + _is_two = 2 + _is_ten = 10 INIT: AV* a; SV* temp; @@ -440,7 +352,7 @@ _is_zero(class, x) XSRETURN(1); /* len != 1, can't be '0' */ } temp = *av_fetch(a, 0, 0); /* fetch first element */ - RETURN_MORTAL_BOOL(temp, 0); + RETURN_MORTAL_BOOL(temp, ix); ############################################################################## |