summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-07-05 22:25:12 +0100
committerDavid Mitchell <davem@iabyn.com>2010-07-14 23:06:17 +0100
commit96bafef935f82644670a19c8ca57886c240cd969 (patch)
treee70a660dd400ee683de795ef1d64c76258aae751
parentab95db60dabd8d8c36f2a83a140b52898d8d4f68 (diff)
downloadperl-96bafef935f82644670a19c8ca57886c240cd969.tar.gz
in CLONEf_JOIN_IN, cache found stashes
When joining a thread, we skip cloning a stash if a stash of the same name already exists in the parent thread. Add it to PL_ptr_table too, so we don't have to repeat the expensive name comparison each time
-rw-r--r--sv.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index 88da54b548..13a139090f 100644
--- a/sv.c
+++ b/sv.c
@@ -11071,9 +11071,12 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
something that is bad **/
if (SvTYPE(sstr) == SVt_PVHV) {
const HEK * const hvname = HvNAME_HEK(sstr);
- if (hvname)
+ if (hvname) {
/** don't clone stashes if they already exist **/
- return MUTABLE_SV(gv_stashpvn(HEK_KEY(hvname), HEK_LEN(hvname), 0));
+ dstr = MUTABLE_SV(gv_stashpvn(HEK_KEY(hvname), HEK_LEN(hvname), 0));
+ ptr_table_store(PL_ptr_table, sstr, dstr);
+ return dstr;
+ }
}
}