From f1c1602aa05e6e31a961fec177e6d315ca1db236 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 23 Jul 2021 10:07:05 +0000 Subject: 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. --- mro_core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'mro_core.c') 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; -- cgit v1.2.1