Optimize Store persistence by eliminating deep clone of internal lock, and optimize relation merging by using retain deduplication.

This commit is contained in:
Riz Ashraf committed 2026-09-21 06:22:05 +01:00
1 parent a9885a65d7
commit e098c257c2
3 files changed
+20 -27

No files matched your search

+2 -5
View File
@@ -31,12 +31,9 @@ pub struct MemoryState {
}
impl MemoryState {
pub fn unique_items<T: Eq + std::hash::Hash + Clone>(input: Vec<T>) -> Vec<T> {
pub fn deduplicate<T: Eq + std::hash::Hash + Clone>(input: &mut Vec<T>) {
let mut keys = std::collections::HashSet::new();
input
.into_iter()
.filter(|entry| keys.insert(entry.clone()))
.collect()
input.retain(|entry| keys.insert(entry.clone()));
}
pub fn broadcast_activity(&self, message: &str) {