diff options
-rw-r--r-- | op.c | 11 | ||||
-rw-r--r-- | pp.c | 5 | ||||
-rw-r--r-- | sv.c | 10 | ||||
-rw-r--r-- | toke.c | 12 |
4 files changed, 17 insertions, 21 deletions
@@ -1534,10 +1534,7 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs, bool for_my) /* fake up C<use attributes $pkg,$rv,@attrs> */ ENTER; /* need to protect against side-effects of 'use' */ SAVEINT(PL_expect); - if (stash) - stashsv = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash)); - else - stashsv = &PL_sv_no; + stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no; #define ATTRSMODULE "attributes" #define ATTRSMODULE_PM "attributes.pm" @@ -1587,10 +1584,8 @@ S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, OP **imopsp) pack = newSVOP(OP_CONST, 0, newSVpvn(ATTRSMODULE, sizeof(ATTRSMODULE)-1)); /* Build up the real arg-list. */ - if (stash) - stashsv = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash)); - else - stashsv = &PL_sv_no; + stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no; + arg = newOP(OP_PADSV, 0); arg->op_targ = target->op_targ; arg = prepend_elem(OP_LIST, @@ -600,9 +600,8 @@ PP(pp_gelem) break; case 'P': if (strEQ(elem2, "ACKAGE")) { - const char *name = HvNAME_get(GvSTASH(gv)); - sv = newSVpvn(name ? name : "__ANON__", - name ? HvNAMELEN_get(GvSTASH(gv)) : 8); + const HEK *hek = HvNAME_HEK(GvSTASH(gv)); + sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8); } break; case 'S': @@ -7606,7 +7606,8 @@ Perl_newSVpvn(pTHX_ const char *s, STRLEN len) =for apidoc newSVpv_hek Creates a new SV from the hash key structure. It will generate scalars that -point to the shared string table where possible. +point to the shared string table where possible. Returns a new (undefined) +SV if the hek is NULL. =cut */ @@ -7614,6 +7615,13 @@ point to the shared string table where possible. SV * Perl_newSVhek(pTHX_ const HEK *hek) { + if (!hek) { + SV *sv; + + new_SV(sv); + return sv; + } + if (HEK_LEN(hek) == HEf_SVKEY) { return newSVsv(*(SV**)HEK_KEY(hek)); } else { @@ -4346,8 +4346,7 @@ Perl_yylex(pTHX) case KEY___PACKAGE__: yylval.opval = (OP*)newSVOP(OP_CONST, 0, (PL_curstash - ? newSVpvn(HvNAME_get(PL_curstash), - HvNAMELEN_get(PL_curstash)) + ? newSVhek(HvNAME_HEK(PL_curstash)) : &PL_sv_undef)); TERM(THING); @@ -5540,9 +5539,7 @@ S_pending_ident(pTHX) /* build ops for a bareword */ HV *stash = PAD_COMPNAME_OURSTASH(tmp); HEK *stashname = HvNAME_HEK(stash); - SV *sym = stashname - ? newSVpvn(HEK_KEY(stashname), HEK_LEN(stashname)) - : newSVpvn(0, 0); + SV *sym = newSVhek(stashname); sv_catpvn(sym, "::", 2); sv_catpv(sym, PL_tokenbuf+1); yylval.opval = (OP*)newSVOP(OP_CONST, 0, sym); @@ -9744,10 +9741,7 @@ S_scan_inputsymbol(pTHX_ char *start) if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { HV *stash = PAD_COMPNAME_OURSTASH(tmp); HEK *stashname = HvNAME_HEK(stash); - SV *sym = sv_2mortal(stashname - ? newSVpvn(HEK_KEY(stashname), - HEK_LEN(stashname)) - : newSVpvn(0, 0)); + SV *sym = sv_2mortal(newSVhek(stashname)); sv_catpvn(sym, "::", 2); sv_catpv(sym, d+1); d = SvPVX(sym); |