refactor: apply rust best practices and fix memory optimizations

- Optimized memory allocation in router.rs by offloading JSON serialization to spawn_blocking and using references.
- Prevented full graph duplication on startup in state.rs index rebuild.
- Eliminated massive String allocations in QueryGraphPathHandler BFS loops.
- Avoided temporary Strings in VisualizeGraphHandler via inline writing.
- Fixed O(N) full-graph deduplication in MergeEntitiesHandler to scale efficiently.
This commit is contained in:
Riz Ashraf committed 2026-09-22 22:01:38 +01:00
1 parent 251757f8fc
commit 37003be620
17 files changed
+399 -198

No files matched your search

+2 -3
View File
@@ -36,7 +36,7 @@ mod tests {
use super::*;
use schemars::JsonSchema;
use serde::Serialize;
#[derive(JsonSchema, Serialize)]
struct DummyTool {
name: String,
@@ -66,11 +66,10 @@ mod tests {
assert_eq!(def["name"], "dummy");
assert_eq!(def["description"], "A dummy tool");
assert!(def["inputSchema"].is_object());
let schema = def["inputSchema"].as_object().unwrap();
let properties = schema["properties"].as_object().unwrap();
assert!(properties.contains_key("name"));
assert!(properties.contains_key("age"));
}
}