perf(server): eliminate implicit full-collection clones by removing Store::read() in favor of read_with()
This commit is contained in:
1 parent
84ad64156c
commit
1d5e4bd00d
8 files changed
+80
-23
No files matched your search
+6
-6
@@ -46,7 +46,7 @@ impl MemoryState {
|
||||
}
|
||||
|
||||
pub fn get_full_graph(&self) -> KnowledgeGraph {
|
||||
self.graph.read()
|
||||
self.graph.read_with(|g| g.clone())
|
||||
}
|
||||
|
||||
pub fn read_graph<F, R>(&self, f: F) -> R
|
||||
@@ -62,12 +62,12 @@ impl MemoryState {
|
||||
|
||||
pub async fn rebuild_index(&self) {
|
||||
if let Ok(new_idx) = MemoryIndex::new(&self.base_dir) {
|
||||
let entities = self.graph.read().entities.into_values().collect();
|
||||
let tasks = self.tasks.read();
|
||||
let snippets = self.snippets.read();
|
||||
let adrs = self.adrs.read();
|
||||
let entities: Vec<Entity> = self.graph.read_with(|g| g.entities.values().cloned().collect());
|
||||
let tasks = self.tasks.read_with(|t| t.clone());
|
||||
let snippets = self.snippets.read_with(|s| s.clone());
|
||||
let adrs = self.adrs.read_with(|a| a.clone());
|
||||
|
||||
let handle = new_idx.index_batch(entities, tasks, snippets, adrs);
|
||||
let handle = new_idx.index_batch(&entities, &tasks, &snippets, &adrs);
|
||||
let _ = handle.await;
|
||||
|
||||
let _ = new_idx.commit().await;
|
||||
|
||||
Reference in new issue
Block a user