summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@pobox.com>2011-08-12 17:45:05 -0700
committerChip Salzenberg <chip@pobox.com>2011-08-12 17:45:05 -0700
commit13dc07cdac031027ff4a529a4c28f3d2b2c4ad9e (patch)
tree157f63b730835d429cd521e9ddf23410abb58c6d
parentfc6d6ec43f51bd9a2300071e36201f5fefe8c21c (diff)
downloadperl-13dc07cdac031027ff4a529a4c28f3d2b2c4ad9e.tar.gz
minimize copy of strings as well as numbers; tweak pad.c which assumed otherwise
-rw-r--r--pad.c4
-rw-r--r--sv.c16
2 files changed, 16 insertions, 4 deletions
diff --git a/pad.c b/pad.c
index da35a09cad..406b9d9db2 100644
--- a/pad.c
+++ b/pad.c
@@ -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,
diff --git a/sv.c b/sv.c
index b7074503b6..8eb8c0578d 100644
--- a/sv.c
+++ b/sv.c
@@ -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: