summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-25 14:53:19 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-25 14:58:58 +0100
commit4019471ab8ddebeb44293629dde165abe0dbb752 (patch)
treee0891365c1bf42141e7f824730aab0c0fc56089b /dist
parent71eb6d8cfb246d23c05d58a2404b8e67ca3e8968 (diff)
downloadperl-4019471ab8ddebeb44293629dde165abe0dbb752.tar.gz
In FastCalc.xs, use SV * as the return type for _new() and _zero()
Previously these were using AV *. Whilst the code always was managing references correctly, to work around the deficiency of the standard typemap entry for AV * it had to mortalise the array it created, meaning that it was creating 2 entries per call on the mortals stack, not 1.
Diffstat (limited to 'dist')
-rw-r--r--dist/Math-BigInt-FastCalc/FastCalc.xs20
1 files changed, 10 insertions, 10 deletions
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs
index d8a5445089..33f4b130e0 100644
--- a/dist/Math-BigInt-FastCalc/FastCalc.xs
+++ b/dist/Math-BigInt-FastCalc/FastCalc.xs
@@ -46,22 +46,20 @@ _set_XS_BASE(BASE, BASE_LEN)
##############################################################################
# _new
-AV *
+SV *
_new(class, x)
SV* x
INIT:
STRLEN len;
char* cur;
STRLEN part_len;
+ AV *av = newAV();
CODE:
- /* create the array */
- RETVAL = newAV();
- sv_2mortal((SV*)RETVAL);
if (SvUOK(x) && SvUV(x) < XS_BASE)
{
/* shortcut for integer arguments */
- av_push (RETVAL, newSVuv( SvUV(x) ));
+ av_push (av, newSVuv( SvUV(x) ));
}
else
{
@@ -87,10 +85,11 @@ _new(class, x)
/* printf ("part '%s' (part_len: %i, len: %i, BASE_LEN: %i)\n", cur, part_len, len, XS_BASE_LEN); */
if (part_len > 0)
{
- av_push (RETVAL, newSVpvn(cur, part_len) );
+ av_push (av, newSVpvn(cur, part_len) );
}
}
}
+ RETVAL = newRV_noinc((SV *)av);
OUTPUT:
RETVAL
@@ -296,16 +295,17 @@ _num(class,x)
##############################################################################
-AV *
+SV *
_zero(class)
ALIAS:
_one = 1
_two = 2
_ten = 10
+ PREINIT:
+ AV *av = newAV();
CODE:
- RETVAL = newAV();
- sv_2mortal((SV*)RETVAL);
- av_push (RETVAL, newSViv( ix ));
+ av_push (av, newSViv( ix ));
+ RETVAL = newRV_noinc((SV *)av);
OUTPUT:
RETVAL