From fdc5118ee2a572ff6ea26e93aafc3f43cbc971d3 Mon Sep 17 00:00:00 2001 From: Dragyx <66752602+Dragyx@users.noreply.github.com> Date: Thu, 8 May 2025 11:31:25 +0200 Subject: [PATCH] store: cache prepared sql statements --- src/store.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store.rs b/src/store.rs index 84c3684..d62c17e 100644 --- a/src/store.rs +++ b/src/store.rs @@ -64,7 +64,7 @@ pub fn get_packages(path: &std::path::Path) -> Result> { let p: String = path.canonicalize()?.to_string_lossy().into_owned(); let conn = Connection::open(DATABASE_URL)?; - let mut stmt = conn.prepare(QUERY_PKGS)?; + let mut stmt = conn.prepare_cached(QUERY_PKGS)?; let queried_pkgs: std::result::Result, _> = stmt .query_map([p], |row| Ok((row.get(0)?, row.get(1)?)))? .collect(); @@ -82,7 +82,7 @@ pub fn get_closure_size(path: &std::path::Path) -> Result { let p: String = path.canonicalize()?.to_string_lossy().into_owned(); let conn = Connection::open(DATABASE_URL)?; - let mut stmt = conn.prepare(QUERY_CLOSURE_SIZE)?; + let mut stmt = conn.prepare_cached(QUERY_CLOSURE_SIZE)?; let queried_sum = stmt.query_row([p], |row| row.get(0))?; Ok(queried_sum) } @@ -101,7 +101,7 @@ pub fn get_dependency_graph(path: &std::path::Path) -> Result>::new(); let queried_edges = stmt.query_map([p], |row| Ok::<(i64, i64), _>((row.get(0)?, row.get(1)?)))?;