mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-15 04:02:18 +08:00
Cache param count and make statement cache more effective
This commit is contained in:
committed by
Thom Chiovoloni
parent
6485b324d7
commit
a776f460e8
@@ -9,3 +9,18 @@ pub(crate) use small_cstr::SmallCString;
|
||||
mod sqlite_string;
|
||||
#[cfg(any(feature = "modern_sqlite", feature = "vtab"))]
|
||||
pub(crate) use sqlite_string::SqliteMallocString;
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn get_cached<T, F>(cache: &std::cell::Cell<Option<T>>, lookup: F) -> T
|
||||
where
|
||||
T: Copy,
|
||||
F: FnOnce() -> T,
|
||||
{
|
||||
if let Some(v) = cache.get() {
|
||||
v
|
||||
} else {
|
||||
let cb = lookup();
|
||||
cache.set(Some(cb));
|
||||
cb
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user