summaryrefslogtreecommitdiff
path: root/mro_core.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-07-23 10:07:05 +0000
committerNicholas Clark <nick@ccl4.org>2021-07-26 07:06:00 +0000
commitf1c1602aa05e6e31a961fec177e6d315ca1db236 (patch)
treea557e5747b3b7bfbe35cdcc6b4a193138ad2f136 /mro_core.c
parent5ebe3ee8a2e8df14624495256026a546dbf8c1dc (diff)
downloadperl-f1c1602aa05e6e31a961fec177e6d315ca1db236.tar.gz
S_mro_gather_and_rename() can use HvTOTALKEYS(), as placeholders don't matter.
Stashes *shouldn't* have placeholders, but even if they did, the loop skips if !isGV(val) is true, which will hold for placeholders. Also move the call to hv_fetchhek() after the check for main::main::main::... The C compiler can't optimise that call away because it doesn't know whether it has has side effects. We know that it doesn't, so we can move it.
Diffstat (limited to 'mro_core.c')
-rw-r--r--mro_core.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mro_core.c b/mro_core.c
index 8e8ed3bac0..24f4c536fc 100644
--- a/mro_core.c
+++ b/mro_core.c
@@ -1110,7 +1110,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
ing that here, as we want to avoid resetting the hash iterator. */
/* Skip the entire loop if the hash is empty. */
- if(oldstash && HvUSEDKEYS(oldstash)) {
+ if(oldstash && HvTOTALKEYS(oldstash)) {
xhv = (XPVHV*)SvANY(oldstash);
seen = (HV *) sv_2mortal((SV *)newHV());
@@ -1134,13 +1134,14 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
if ((len > 1 && key[len-2] == ':' && key[len-1] == ':')
|| (len == 1 && key[0] == ':')) {
HV * const oldsubstash = GvHV(HeVAL(entry));
- SV ** const stashentry
- = stash ? hv_fetchhek(stash, HeKEY_hek(entry), 0) : NULL;
+ SV **stashentry;
HV *substash = NULL;
/* Avoid main::main::main::... */
if(oldsubstash == oldstash) continue;
+ stashentry = stash ? hv_fetchhek(stash, HeKEY_hek(entry), 0) : NULL;
+
if(
(
stashentry && *stashentry && isGV(*stashentry)
@@ -1196,7 +1197,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes,
}
/* Skip the entire loop if the hash is empty. */
- if (stash && HvUSEDKEYS(stash)) {
+ if (stash && HvTOTALKEYS(stash)) {
xhv = (XPVHV*)SvANY(stash);
riter = -1;