summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-01-09 21:26:40 +0000
committerNicholas Clark <nick@ccl4.org>2005-01-09 21:26:40 +0000
commit2e0de35c58680e1e008b1d014c5b9ccec5b78282 (patch)
treeca49feb20f6ec1dffdbc11370070a0173467afe2 /mg.c
parent8a7a129d01690124356e6e97ab81becf500e68af (diff)
downloadperl-2e0de35c58680e1e008b1d014c5b9ccec5b78282.tar.gz
savepv(SvPV(sv,n_a)) is common, and creates an unnecessary call to
strlen(). Add savesvpv(sv), which gets the length from the SV, and returns a copy of its PV. p4raw-id: //depot/perl@23772
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mg.c b/mg.c
index 255e2082e5..c24bf6de73 100644
--- a/mg.c
+++ b/mg.c
@@ -2118,7 +2118,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
if (PL_inplace)
Safefree(PL_inplace);
if (SvOK(sv))
- PL_inplace = savepv(SvPV(sv,len));
+ PL_inplace = savesvpv(sv);
else
PL_inplace = Nullch;
break;
@@ -2130,7 +2130,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
}
if (SvOK(sv)) {
TAINT_PROPER("assigning to $^O");
- PL_osname = savepv(SvPV(sv,len));
+ PL_osname = savesvpv(sv);
}
}
else if (strEQ(mg->mg_ptr, "\017PEN")) {
@@ -2206,12 +2206,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
break;
case '^':
Safefree(IoTOP_NAME(GvIOp(PL_defoutgv)));
- IoTOP_NAME(GvIOp(PL_defoutgv)) = s = savepv(SvPV(sv,len));
+ IoTOP_NAME(GvIOp(PL_defoutgv)) = s = savesvpv(sv);
IoTOP_GV(GvIOp(PL_defoutgv)) = gv_fetchsv(sv,TRUE, SVt_PVIO);
break;
case '~':
Safefree(IoFMT_NAME(GvIOp(PL_defoutgv)));
- IoFMT_NAME(GvIOp(PL_defoutgv)) = s = savepv(SvPV(sv,len));
+ IoFMT_NAME(GvIOp(PL_defoutgv)) = s = savesvpv(sv);
IoFMT_GV(GvIOp(PL_defoutgv)) = gv_fetchsv(sv,TRUE, SVt_PVIO);
break;
case '=':
@@ -2269,7 +2269,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
case '#':
if (PL_ofmt)
Safefree(PL_ofmt);
- PL_ofmt = savepv(SvPV(sv,len));
+ PL_ofmt = savesvpv(sv);
break;
case '[':
PL_compiling.cop_arybase = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);