refactor: remove redundant multi-line search index unwrap clones across all handlers via new get_search_index accessor

This commit is contained in:
Riz Ashraf committed 2026-09-26 08:39:42 +01:00
1 parent d96b4cf822
commit 0ba0ed5b3d
5 files changed
+12 -36

No files matched your search

+2 -6
View File
@@ -21,11 +21,7 @@ impl McpTool for LogDecisionHandler {
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
let req: LogDecisionTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
let idx = state
.search_index
.read()
.unwrap_or_else(|e| e.into_inner())
.clone();
let idx = state.get_search_index();
let mut final_id = String::new();
state.adrs.modify(|adrs| {
@@ -344,7 +340,7 @@ impl McpTool for OmniSearchHandler {
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
let req: OmniSearchTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
let matches = {
let idx = state.search_index.read().unwrap_or_else(|e| e.into_inner());
let idx = state.get_search_index();
idx.search(&req.query, req.namespace.as_deref())
.unwrap_or_default()
};