diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-02-18 19:40:43 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-02-18 19:40:43 +0000 |
commit | b9f83d2f7c4cb24d96302c6fcaa5e60628fad1f8 (patch) | |
tree | 65417bf74a7dc6b1ad198dcf0f64abbe38d16a66 /pad.c | |
parent | be2b1c742382f74864880924170180bbe1904463 (diff) | |
download | perl-b9f83d2f7c4cb24d96302c6fcaa5e60628fad1f8.tar.gz |
Add a new API function newSV_type, to replace the idiom:
sv = newSV(0);
sv_upgrade(sv, type);
p4raw-id: //depot/perl@30347
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -347,12 +347,11 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake { dVAR; const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY); - SV* const namesv = newSV(0); + SV* const namesv + = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV); ASSERT_CURPAD_ACTIVE("pad_add_name"); - - sv_upgrade(namesv, (ourstash || typestash) ? SVt_PVMG : SVt_PVNV); sv_setpv(namesv, name); if (typestash) { @@ -485,9 +484,8 @@ Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type) { dVAR; PADOFFSET ix; - SV* const name = newSV(0); + SV* const name = newSV_type(SVt_PVNV); pad_peg("add_anon"); - sv_upgrade(name, SVt_PVNV); sv_setpvn(name, "&", 1); /* Are these two actually ever read? */ COP_SEQ_RANGE_HIGH_set(name, ~0); @@ -1457,8 +1455,7 @@ Perl_cv_clone(pTHX_ CV *proto) ENTER; SAVESPTR(PL_compcv); - cv = PL_compcv = (CV*)newSV(0); - sv_upgrade((SV *)cv, SvTYPE(proto)); + cv = PL_compcv = (CV*)newSV_type(SvTYPE(proto)); CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE); CvCLONED_on(cv); |