summaryrefslogtreecommitdiff
path: root/mro.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-08-22 06:10:31 +0000
committerNicholas Clark <nick@ccl4.org>2008-08-22 06:10:31 +0000
commit8e45cc2bb9db96fb730868796fbfe1d0f7ece32d (patch)
tree246b020f826fa1e350efae0d72a3d08ce5779f00 /mro.c
parent785bee4f7cf89837cba8e6e0859abbb4b407e1f1 (diff)
downloadperl-8e45cc2bb9db96fb730868796fbfe1d0f7ece32d.tar.gz
In S_mro_get_linear_isa_dfs(), hv_exists_ent() followed by an optional
hv_store_ent() can be replaced with an lvalue fetch. p4raw-id: //depot/perl@34214
Diffstat (limited to 'mro.c')
-rw-r--r--mro.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/mro.c b/mro.c
index 13dd70a15a..a7ea282dc0 100644
--- a/mro.c
+++ b/mro.c
@@ -185,9 +185,18 @@ S_mro_get_linear_isa_dfs(pTHX_ HV *stash, I32 level)
}
while(subrv_items--) {
SV *const subsv = *subrv_p++;
- if(!hv_exists_ent(stored, subsv, 0)) {
- (void)hv_store_ent(stored, subsv, &PL_sv_undef, 0);
- av_push(retval, newSVsv(subsv));
+ /* LVALUE fetch will create a new undefined SV if necessary
+ */
+ HE *const he = hv_fetch_ent(stored, subsv, 1, 0);
+ assert(he);
+ if(HeVAL(he) != &PL_sv_undef) {
+ /* It was newly created. Steal it for our new SV, and
+ replace it in the hash with the "real" thing. */
+ SV *const val = HeVAL(he);
+
+ HeVAL(he) = &PL_sv_undef;
+ sv_setsv(val, subsv);
+ av_push(retval, val);
}
}
}