Skip to content

Commit

Permalink
Merge pull request #1449 from ljedrz/perf_get_speculative
Browse files Browse the repository at this point in the history
Speed up the happy path for MapRead::get_speculative
  • Loading branch information
howardwu authored Oct 14, 2023
2 parents 1d0e608 + bc39caf commit 6758aaf
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions ledger/store/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,14 @@ pub trait MapRead<
K: Borrow<Q>,
Q: PartialEq + Eq + Hash + Serialize + ?Sized,
{
// Return early in case of errors in order to not conceal them.
let map_value = self.get_confirmed(key)?;

// Retrieve the atomic batch value, if it exists.
let atomic_batch_value = self.get_pending(key);

// Return the atomic batch value, if it exists, or the map value, otherwise.
match atomic_batch_value {
Some(Some(value)) => Ok(Some(Cow::Owned(value))),
Some(None) => Ok(None),
None => Ok(map_value),
None => Ok(self.get_confirmed(key)?),
}
}

Expand Down

0 comments on commit 6758aaf

Please sign in to comment.