diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-05-31 13:19:22 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-05-31 13:19:22 +0100 |
commit | c1bf42f3e6ad8f1c3d821a2ae616c5703f66237c (patch) | |
tree | b9f534e9a7e7761c09a8570e021dafb745662fa5 /pad.c | |
parent | 4c050ad563ece4467b3b083d8efcf2b62ad0b9c5 (diff) | |
download | perl-c1bf42f3e6ad8f1c3d821a2ae616c5703f66237c.tar.gz |
In Perl_pad_add_name(), use sv_upgrade() directly rather than new[AH]V().
As newAV() and newHV() are now merely wrappers around sv_upgrade(), and the
existing SV is always brand new and of type SVt_NULL, call them on it, rather
than disposing of it as a side effect of storing a(nother new) SV.
Also, no need to set SvPADMY() again, as it is already set.
Resolves RT #73092.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -420,13 +420,13 @@ Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags, PL_min_intro_pending = offset; PL_max_intro_pending = offset; /* if it's not a simple scalar, replace with an AV or HV */ - /* XXX DAPM since slot has been allocated, replace - * av_store with PL_curpad[offset] ? */ + assert(SvTYPE(PL_curpad[offset]) == SVt_NULL); + assert(SvREFCNT(PL_curpad[offset]) == 1); if (*name == '@') - av_store(PL_comppad, offset, MUTABLE_SV(newAV())); + sv_upgrade(PL_curpad[offset], SVt_PVAV); else if (*name == '%') - av_store(PL_comppad, offset, MUTABLE_SV(newHV())); - SvPADMY_on(PL_curpad[offset]); + sv_upgrade(PL_curpad[offset], SVt_PVHV); + assert(SvPADMY(PL_curpad[offset])); DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad addname: %ld \"%s\" new lex=0x%"UVxf"\n", (long)offset, name, PTR2UV(PL_curpad[offset]))); |