From 95814bf633d2ce10446c1023dedb00f8c40ac6c2 Mon Sep 17 00:00:00 2001 From: elvis Date: Mon, 22 Dec 2025 15:24:21 +0100 Subject: [PATCH] Minor improvement --- reaction_systems_gui/src/app.rs | 23 +++++++++++------------ reaction_systems_gui/src/app_logic.rs | 3 +-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/reaction_systems_gui/src/app.rs b/reaction_systems_gui/src/app.rs index 6054100..026f5c7 100644 --- a/reaction_systems_gui/src/app.rs +++ b/reaction_systems_gui/src/app.rs @@ -836,12 +836,12 @@ impl OutputsCache { s.finish() } - pub fn input_hashes(&self, key: &OutputId) -> Option> { + pub(crate) fn input_hashes(&self, key: &OutputId) -> Option> { let internals = self.internals.read().unwrap(); internals.hash_inputs.get(key).map(|el| el.1.to_vec()) } - pub fn same_hash_inputs(&self, key: &OutputId, inputs: &[u64]) -> bool { + pub(crate) fn same_hash_inputs(&self, key: &OutputId, inputs: &[u64]) -> bool { let hash_inputs = inputs.iter().fold(0, |acc, x| acc ^ x); let internals = self.internals.read().unwrap(); internals @@ -860,7 +860,7 @@ impl OutputsCache { internals.hash_inputs.insert(key, (hash_inputs, inputs)); } - pub fn retrieve_cache_output( + pub(crate) fn retrieve_cache_output( &self, graph: &NodeGraph, node_id: NodeId, @@ -880,12 +880,12 @@ impl OutputsCache { } } - pub fn retrieve_output(&self, key: OutputId) -> Option { + pub(crate) fn retrieve_output(&self, key: OutputId) -> Option { let internals = self.internals.read().unwrap(); internals.values.get(&key).cloned() } - pub fn populate_output( + pub(crate) fn populate_output( &self, graph: &NodeGraph, node_id: NodeId, @@ -898,36 +898,35 @@ impl OutputsCache { Ok(()) } - pub fn invalidate_cache(&self, key: &OutputId) { + pub(crate) fn invalidate_cache(&self, key: &OutputId) { let mut internals = self.internals.write().unwrap(); internals.hash_inputs.remove(key); internals.hash_values.remove(key); internals.values.remove(key); } - pub fn invalidate_outputs(&self, graph: &NodeGraph, node_id: NodeId) { + pub(crate) fn invalidate_outputs(&self, graph: &NodeGraph, node_id: NodeId) { for output_id in graph[node_id].output_ids() { self.invalidate_cache(&output_id); } } - #[allow(dead_code)] - pub fn reset_cache(&self) { + pub(crate) fn reset_cache(&self) { let mut internals = self.internals.write().unwrap(); *internals = CacheInternals::default(); } - pub fn get_last_state(&self) -> Option { + pub(crate) fn get_last_state(&self) -> Option { let internals = self.internals.read().unwrap(); internals.last_output.clone() } - pub fn invalidate_last_state(&self) { + pub(crate) fn invalidate_last_state(&self) { let mut internals = self.internals.write().unwrap(); internals.last_output = None; } - pub fn set_last_state(&self, val: BasicValue) { + pub(crate) fn set_last_state(&self, val: BasicValue) { let mut internals = self.internals.write().unwrap(); internals.last_output = Some(val); } diff --git a/reaction_systems_gui/src/app_logic.rs b/reaction_systems_gui/src/app_logic.rs index d91f61a..1ce6715 100644 --- a/reaction_systems_gui/src/app_logic.rs +++ b/reaction_systems_gui/src/app_logic.rs @@ -105,14 +105,13 @@ fn generate_to_evaluate( } } } - dependencies.reverse(); // then keep only the ones that have an input that is different or not // cached let mut res = vec![]; let mut invalid_ids = HashSet::new(); - for n_id in dependencies { + for &n_id in dependencies.iter().rev() { let mut input_hashes = vec![]; match graph[n_id].user_data.template {