diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-06-22 20:45:23 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-06-22 20:45:23 +0100 |
commit | 6eb667c676e523c76dfdaf169fce3797599bd851 (patch) | |
tree | 6f7590778976260b05d3baf0074e136c536632fc /hv.c | |
parent | 53409900a7d39827c92521617aae4258229bce49 (diff) | |
download | perl-6eb667c676e523c76dfdaf169fce3797599bd851.tar.gz |
Instead of a const char *, pass a HEK * to anonymise_cv().
This will cope properly with Unicode package names. It also allows use of more
efficient perl API calls, avoiding any strlen()s.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -1468,7 +1468,7 @@ Perl_hv_free_ent(pTHX_ HV *hv, register HE *entry) if (!entry) return; val = HeVAL(entry); - if (HvNAME(hv) && anonymise_cv(HvNAME(hv), val) && GvCVu(val)) + if (HvNAME(hv) && anonymise_cv(HvNAME_HEK(hv), val) && GvCVu(val)) mro_method_changed_in(hv); SvREFCNT_dec(val); if (HeKLEN(entry) == HEf_SVKEY) { @@ -1483,7 +1483,7 @@ Perl_hv_free_ent(pTHX_ HV *hv, register HE *entry) } static I32 -S_anonymise_cv(pTHX_ const char *stash, SV *val) +S_anonymise_cv(pTHX_ HEK *stash, SV *val) { CV *cv; @@ -1491,12 +1491,17 @@ S_anonymise_cv(pTHX_ const char *stash, SV *val) if (val && isGV(val) && isGV_with_GP(val) && (cv = GvCV(val))) { if ((SV *)CvGV(cv) == val) { - SV *gvname; GV *anongv; - gvname = Perl_newSVpvf(aTHX_ "%s::__ANON__", stash ? stash : "__ANON__"); - anongv = gv_fetchsv(gvname, GV_ADDMULTI, SVt_PVCV); - SvREFCNT_dec(gvname); + if (stash) { + SV *gvname = newSVhek(stash); + sv_catpvs(gvname, "::__ANON__"); + anongv = gv_fetchsv(gvname, GV_ADDMULTI, SVt_PVCV); + SvREFCNT_dec(gvname); + } else { + anongv = gv_fetchpvs("__ANON__::__ANON__", GV_ADDMULTI, + SVt_PVCV); + } CvGV(cv) = anongv; CvANON_on(cv); return 1; |