summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-10-18 18:06:29 +0000
committerNicholas Clark <nick@ccl4.org>2007-10-18 18:06:29 +0000
commit49a54bbe5e246f5f51e51453d9cc5a19e72a4433 (patch)
tree95c13d0218c4813cdf5947b181e8bdfe96f76e4b /gv.c
parent9ff8e8065ea8557fda504cf7c2337bef185cd00f (diff)
downloadperl-49a54bbe5e246f5f51e51453d9cc5a19e72a4433.tar.gz
Eliminate some uses of sv_setpv() where we already know the length.
Donate the prototype buffer to the CV in Perl_gv_init(), rather than setting a copy, and immediately free()ing the original. p4raw-id: //depot/perl@32136
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index d34d04328c..24dabf64e5 100644
--- a/gv.c
+++ b/gv.c
@@ -214,6 +214,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
const U32 old_type = SvTYPE(gv);
const bool doproto = old_type > SVt_NULL;
const char * const proto = (doproto && SvPOK(gv)) ? SvPVX_const(gv) : NULL;
+ const STRLEN protolen = proto ? SvCUR(gv) : 0;
SV *const has_constant = doproto && SvROK(gv) ? SvRV(gv) : NULL;
const U32 exported_constant = has_constant ? SvPCS_IMPORTED(gv) : 0;
@@ -280,8 +281,8 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
CvFILE_set_from_cop(GvCV(gv), PL_curcop);
CvSTASH(GvCV(gv)) = PL_curstash;
if (proto) {
- sv_setpv((SV*)GvCV(gv), proto);
- Safefree(proto);
+ sv_usepvn_flags((SV*)GvCV(gv), proto, protolen,
+ SV_HAS_TRAILING_NUL);
}
}
}