summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-02-02 11:05:17 +0000
committerNicholas Clark <nick@ccl4.org>2008-02-02 11:05:17 +0000
commit92e45a3e6a37177cdf8021650cda6bd5a43fdbdf (patch)
tree73fdbcaeb0f29946f7d0689a0cd48c96c9cef7f9 /universal.c
parentfb632ce3b9716ad53f50ed424ce0956dc2d24e5d (diff)
downloadperl-92e45a3e6a37177cdf8021650cda6bd5a43fdbdf.tar.gz
In XS_PerlIO_get_layers() take advantage of the implementation of
PerlIO_get_layers(), by co-opting the new SVs it creates, rather than copying them. p4raw-id: //depot/perl@33182
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/universal.c b/universal.c
index 6860cec2ad..ce73c823cc 100644
--- a/universal.c
+++ b/universal.c
@@ -969,16 +969,22 @@ XS(XS_PerlIO_get_layers)
const bool flgok = flgsvp && *flgsvp && SvIOK(*flgsvp);
if (details) {
+ /* Indents of 5? Yuck. */
+ /* We know that PerlIO_get_layers creates a new SV for
+ the name and flags, so we can just take a reference
+ and "steal" it when we free the AV below. */
XPUSHs(namok
- ? sv_2mortal(newSVpvn(SvPVX_const(*namsvp), SvCUR(*namsvp)))
+ ? sv_2mortal(SvREFCNT_inc_simple_NN(*namsvp))
: &PL_sv_undef);
XPUSHs(argok
- ? sv_2mortal(newSVpvn(SvPVX_const(*argsvp), SvCUR(*argsvp)))
+ ? newSVpvn_flags(SvPVX_const(*argsvp),
+ SvCUR(*argsvp),
+ (SvUTF8(*argsvp) ? SVf_UTF8 : 0)
+ | SVs_TEMP)
+ : &PL_sv_undef);
+ XPUSHs(namok
+ ? sv_2mortal(SvREFCNT_inc_simple_NN(*flgsvp))
: &PL_sv_undef);
- if (flgok)
- mXPUSHi(SvIVX(*flgsvp));
- else
- XPUSHs(&PL_sv_undef);
nitem += 3;
}
else {
@@ -987,8 +993,7 @@ XS(XS_PerlIO_get_layers)
SVfARG(*namsvp),
SVfARG(*argsvp))));
else if (namok)
- XPUSHs(sv_2mortal(Perl_newSVpvf(aTHX_ "%"SVf,
- SVfARG(*namsvp))));
+ XPUSHs(sv_2mortal(SvREFCNT_inc_simple_NN(*namsvp)));
else
XPUSHs(&PL_sv_undef);
nitem++;