Skip to content

Commit

Permalink
Where the key is an SV, replace some hv_* calls with hv_*_ent equival…
Browse files Browse the repository at this point in the history
…ents.

This avoids the SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr)
code dance.
  • Loading branch information
nwc10 committed Jul 26, 2021
1 parent 0cdaae3 commit bffed14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
8 changes: 4 additions & 4 deletions mro_core.c
Expand Up @@ -958,9 +958,8 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
if(PL_stashcache) {
DEBUG_o(Perl_deb(aTHX_ "mro_gather_and_rename clearing PL_stashcache for '%" SVf "'\n",
SVfARG(*svp)));
(void)hv_delete(PL_stashcache, name, name_utf8 ? -(I32)len : (I32)len, G_DISCARD);
(void)hv_delete_ent(PL_stashcache, *svp, G_DISCARD, 0);
}
++svp;
hv_ename_delete(oldstash, name, len, name_utf8);

if (!fetched_isarev) {
Expand All @@ -976,11 +975,12 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
if(meta->isa && HvARRAY(meta->isa))
mro_clean_isarev(meta->isa, name, len, 0, 0,
name_utf8 ? HVhek_UTF8 : 0);
isarev = (HV *)hv_delete(PL_isarev, name,
name_utf8 ? -(I32)len : (I32)len, 0);
isarev = (HV *)hv_delete_ent(PL_isarev, *svp, 0, 0);
fetched_isarev=TRUE;
}
}

++svp;
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions op.c
Expand Up @@ -11142,10 +11142,9 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)

sv_catpvn_flags(tmpstr, PadnamePV(name)+1, PadnameLEN(name)-1,
PadnameUTF8(name) ? SV_CATUTF8 : SV_CATBYTES);
(void)hv_store(GvHV(PL_DBsub), SvPVX_const(tmpstr),
SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr), sv, 0);
(void)hv_store_ent(GvHV(PL_DBsub), tmpstr, sv, 0);
hv = GvHVn(db_postponed);
if (HvTOTALKEYS(hv) > 0 && hv_exists(hv, SvPVX_const(tmpstr), SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr))) {
if (HvTOTALKEYS(hv) > 0 && hv_exists_ent(hv, tmpstr, 0)) {
CV * const pcv = GvCV(db_postponed);
if (pcv) {
dSP;
Expand Down Expand Up @@ -11722,10 +11721,9 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
CopFILE(PL_curcop),
(long)PL_subline,
(long)CopLINE(PL_curcop));
(void)hv_store(GvHV(PL_DBsub), SvPVX_const(tmpstr),
SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr), sv, 0);
(void)hv_store_ent(GvHV(PL_DBsub), tmpstr, sv, 0);
hv = GvHVn(db_postponed);
if (HvTOTALKEYS(hv) > 0 && hv_exists(hv, SvPVX_const(tmpstr), SvUTF8(tmpstr) ? -(I32)SvCUR(tmpstr) : (I32)SvCUR(tmpstr))) {
if (HvTOTALKEYS(hv) > 0 && hv_exists_ent(hv, tmpstr, 0)) {
CV * const pcv = GvCV(db_postponed);
if (pcv) {
dSP;
Expand Down
6 changes: 2 additions & 4 deletions pp_ctl.c
Expand Up @@ -1687,16 +1687,14 @@ S_pop_eval_context_maybe_croak(pTHX_ PERL_CONTEXT *cx, SV *errsv, int action)
if (do_croak) {
const char *fmt;
HV *inc_hv = GvHVn(PL_incgv);
I32 klen = SvUTF8(namesv) ? -(I32)SvCUR(namesv) : (I32)SvCUR(namesv);
const char *key = SvPVX_const(namesv);

if (action == 1) {
(void)hv_delete(inc_hv, key, klen, G_DISCARD);
(void)hv_delete_ent(inc_hv, namesv, G_DISCARD, 0);
fmt = "%" SVf " did not return a true value";
errsv = namesv;
}
else {
(void)hv_store(inc_hv, key, klen, &PL_sv_undef, 0);
(void)hv_store_ent(inc_hv, namesv, &PL_sv_undef, 0);
fmt = "%" SVf "Compilation failed in require";
if (!errsv)
errsv = newSVpvs_flags("Unknown error\n", SVs_TEMP);
Expand Down

0 comments on commit bffed14

Please sign in to comment.