summaryrefslogtreecommitdiff
path: root/mro_core.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-07-20 20:05:44 +0000
committerNicholas Clark <nick@ccl4.org>2021-07-26 07:06:00 +0000
commit5ebe3ee8a2e8df14624495256026a546dbf8c1dc (patch)
tree428ae8a07eda7f01ec8814510cc9edb67b72eca7 /mro_core.c
parentbffed14d6aeedc70a2f799ef7c8fe1f5d608eb52 (diff)
downloadperl-5ebe3ee8a2e8df14624495256026a546dbf8c1dc.tar.gz
Convert code in mro_core.c to use hv_*hek() APIs where possible.
Add a macro hv_existshek() to implement exists. The HEK-based macros are more efficient wrappers of hv_common() than the string/length/flags macros because they also pass in the pre-computed hash value (from the HEK). This avoids hv_common() needing to recalculate it.
Diffstat (limited to 'mro_core.c')
-rw-r--r--mro_core.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/mro_core.c b/mro_core.c
index bb513df8cd..8e8ed3bac0 100644
--- a/mro_core.c
+++ b/mro_core.c
@@ -697,18 +697,16 @@ S_mro_clean_isarev(pTHX_ HV * const isa, const char * const name,
if(HvARRAY(isa) && hv_iterinit(isa)) {
SV **svp;
while((iter = hv_iternext(isa))) {
- I32 klen;
- const char * const key = hv_iterkey(iter, &klen);
- if(exceptions && hv_exists(exceptions, key, HeKUTF8(iter) ? -klen : klen))
+ HEK *key = HeKEY_hek(iter);
+ if(exceptions && hv_existshek(exceptions, key))
continue;
- svp = hv_fetch(PL_isarev, key, HeKUTF8(iter) ? -klen : klen, 0);
+ svp = hv_fetchhek(PL_isarev, key, 0);
if(svp) {
HV * const isarev = (HV *)*svp;
(void)hv_common(isarev, NULL, name, len, flags,
G_DISCARD|HV_DELETE, NULL, hash);
if(!HvARRAY(isarev) || !HvUSEDKEYS(isarev))
- (void)hv_delete(PL_isarev, key,
- HeKUTF8(iter) ? -klen : klen, G_DISCARD);
+ (void)hv_deletehek(PL_isarev, key, G_DISCARD);
}
}
}
@@ -1137,7 +1135,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
|| (len == 1 && key[0] == ':')) {
HV * const oldsubstash = GvHV(HeVAL(entry));
SV ** const stashentry
- = stash ? hv_fetch(stash, key, HeUTF8(entry) ? -(I32)len : (I32)len, 0) : NULL;
+ = stash ? hv_fetchhek(stash, HeKEY_hek(entry), 0) : NULL;
HV *substash = NULL;
/* Avoid main::main::main::... */
@@ -1191,7 +1189,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
);
}
- (void)hv_store(seen, key, HeUTF8(entry) ? -(I32)len : (I32)len, &PL_sv_yes, 0);
+ (void)hv_storehek(seen, HeKEY_hek(entry), &PL_sv_yes);
}
}
}
@@ -1223,7 +1221,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
/* If this entry was seen when we iterated through the
oldstash, skip it. */
- if(seen && hv_exists(seen, key, HeUTF8(entry) ? -(I32)len : (I32)len)) continue;
+ if(seen && hv_existshek(seen, HeKEY_hek(entry))) continue;
/* We get here only if this stash has no corresponding
entry in the stash being replaced. */