From ed090c438790a7c82bb93f3841513752973e5da7 Mon Sep 17 00:00:00 2001 From: TOKUNAGA Hiroyuki <96674+tkng@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:38:22 +0900 Subject: [PATCH] perf(core): update joint search spaces in place - Compute completed-trial intersections with HashMap::retain. - Remove repeated map allocation and parameter-name/distribution clones. - Preserve distribution matching and unfinished-trial cursor behavior. --- rustuna_core/src/study_cache.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rustuna_core/src/study_cache.rs b/rustuna_core/src/study_cache.rs index c72aaadf..eb22e104 100644 --- a/rustuna_core/src/study_cache.rs +++ b/rustuna_core/src/study_cache.rs @@ -56,13 +56,9 @@ impl StudyCache { if let TrialStateValues::Complete(_) = trial.state_values { match self.joint_search_space { Some(ref mut search_space) => { - let mut joint_space = HashMap::new(); - for (name, distribution) in search_space.iter() { - if trial.distributions.get(name) == Some(distribution) { - joint_space.insert(name.clone(), distribution.clone()); - } - } - *search_space = joint_space; + search_space.retain(|name, distribution| { + trial.distributions.get(name) == Some(distribution) + }); } None => { self.joint_search_space = Some(trial.distributions.clone());