diff options
author | Chip Salzenberg <chip@pobox.com> | 2011-08-12 17:45:05 -0700 |
---|---|---|
committer | Chip Salzenberg <chip@pobox.com> | 2011-08-12 17:45:05 -0700 |
commit | 13dc07cdac031027ff4a529a4c28f3d2b2c4ad9e (patch) | |
tree | 157f63b730835d429cd521e9ddf23410abb58c6d | |
parent | fc6d6ec43f51bd9a2300071e36201f5fefe8c21c (diff) | |
download | perl-13dc07cdac031027ff4a529a4c28f3d2b2c4ad9e.tar.gz |
minimize copy of strings as well as numbers; tweak pad.c which assumed otherwise
-rw-r--r-- | pad.c | 4 | ||||
-rw-r--r-- | sv.c | 16 |
2 files changed, 16 insertions, 4 deletions
@@ -1243,12 +1243,14 @@ S_pad_findlex(pTHX_ const char *namepv, STRLEN namelen, U32 flags, const CV* cv, type as the source, independent of the flags set, and on it being "good" and only copying flag bits and pointers that it understands. */ - SV *new_namesv = newSVsv(*out_name_sv); AV * const ocomppad_name = PL_comppad_name; PAD * const ocomppad = PL_comppad; PL_comppad_name = MUTABLE_AV(AvARRAY(padlist)[0]); PL_comppad = MUTABLE_AV(AvARRAY(padlist)[1]); PL_curpad = AvARRAY(PL_comppad); + SV *new_namesv = newSVsv(*out_name_sv); + if (SvTYPE(new_namesv) < SVt_PVNV) + sv_upgrade(new_namesv, SVt_PVNV); /* pad names use SvNVX */ new_offset = pad_alloc_name(new_namesv, @@ -4038,8 +4038,14 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags) goto copy_iv; /* IOK is only possibility */ if (!SvOK(sstr)) goto undef_sstr; - if (dtype < SVt_PVIV) - sv_upgrade(dstr, SVt_PVIV); + if (SvIOK(sstr)) { + if (dtype < SVt_PVIV) + sv_upgrade(dstr, SVt_PVIV); + } + else { + if (dtype < SVt_PV) + sv_upgrade(dstr, SVt_PV); + } break; case SVt_PVNV: @@ -4056,10 +4062,14 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags) if (dtype < SVt_PVIV) sv_upgrade(dstr, SVt_PVIV); } - else { + else if (SvNOK(sstr)) { if (dtype < SVt_PVNV) sv_upgrade(dstr, SVt_PVNV); } + else { + if (dtype < SVt_PV) + sv_upgrade(dstr, SVt_PV); + } break; default: |