mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 08:52:56 +00:00
Remove 2/3 clones on search path
This commit is contained in:
@@ -369,10 +369,7 @@ impl<Value: Clone> RetroactiveLayerMap<Value> {
|
||||
panic!("rebuild pls")
|
||||
}
|
||||
|
||||
match self.map.query(key, lsn) {
|
||||
Some(layer) => Some(layer.clone()),
|
||||
None => None,
|
||||
}
|
||||
self.map.query(key, lsn)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,15 +274,21 @@ impl LayerMap {
|
||||
let latest_image = self.images.query(key.to_i128(), end_lsn.0 - 1);
|
||||
|
||||
// Check for exact match
|
||||
if let Some(image) = &latest_image {
|
||||
let latest_image = if let Some(image) = latest_image {
|
||||
let img_lsn = image.get_lsn_range().start;
|
||||
if Lsn(img_lsn.0 + 1) == end_lsn {
|
||||
return Ok(Some(SearchResult {
|
||||
layer: Arc::clone(&image),
|
||||
layer: image,
|
||||
lsn_floor: img_lsn,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// HACK just to give back ownership of latest_image to parent scope.
|
||||
// There's definitely a cleaner way to do it.
|
||||
Some(image)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
return Ok(latest_layer.map(|layer| {
|
||||
// Compute lsn_floor
|
||||
@@ -293,7 +299,7 @@ impl LayerMap {
|
||||
}
|
||||
}
|
||||
SearchResult {
|
||||
layer: Arc::clone(&layer),
|
||||
layer,
|
||||
lsn_floor,
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user