|
@@ -100,15 +100,10 @@ impl<'l> QueryInterface<'l> {
|
|
|
) -> Return {
|
|
|
let mut cache = self.cache.lock().expect("Couldn't acquire cache?");
|
|
|
let key = (context, ty, NO_HASH);
|
|
|
- if !cache.contains_key(&key) {
|
|
|
- cache.insert(key, create());
|
|
|
- }
|
|
|
- let mut query = cache
|
|
|
- .get_mut(&key)
|
|
|
- .expect("Just-inserted item not in cache?");
|
|
|
+ let query = cache.entry(key).or_insert_with(create);
|
|
|
|
|
|
query.reset().expect("Couldn't reset query");
|
|
|
- with(&mut query)
|
|
|
+ with(query)
|
|
|
}
|
|
|
|
|
|
fn cached_query_column<Column: crate::model::EntityColumns, Return>(
|
|
@@ -127,15 +122,10 @@ impl<'l> QueryInterface<'l> {
|
|
|
|
|
|
let mut cache = self.cache.lock().expect("Couldn't acquire cache?");
|
|
|
let key = (context, ty, hash);
|
|
|
- if !cache.contains_key(&key) {
|
|
|
- cache.insert(key, create());
|
|
|
- }
|
|
|
- let mut query = cache
|
|
|
- .get_mut(&key)
|
|
|
- .expect("Just-inserted item not in cache?");
|
|
|
+ let query = cache.entry(key).or_insert_with(create);
|
|
|
|
|
|
query.reset().expect("Couldn't reset query");
|
|
|
- with(&mut query)
|
|
|
+ with(query)
|
|
|
}
|
|
|
|
|
|
/// Search for an entity by a property
|