Skip to content

Commit

Permalink
perf(bolt-sidecar): inline ScoreCache methods
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Nov 27, 2024
1 parent a450dd8 commit 4d6e866
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bolt-sidecar/src/common/score_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ where
/// A wrapper over [std::collections::HashMap::get_mut] that bumps the score of the key.
///
/// Requires mutable access to the cache to update the score.
#[inline]
pub fn get<Q>(&mut self, k: &Q) -> Option<&V>
where
K: Borrow<Q>,
Expand All @@ -162,6 +163,7 @@ where
/// A wrapper over [std::collections::HashMap::get_mut] that bumps the score of the key.
///
/// Requires mutable access to the cache to update the score.
#[inline]
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
where
K: Borrow<Q>,
Expand All @@ -177,6 +179,7 @@ where
///
/// Adds a new key-value pair to the cache with the provided `INSERT_SCORE`, by first trying to
/// clear any stale element from the cache if necessary.
#[inline]
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
self.clear_stales();
self.map.insert(k, (v, INSERT_SCORE)).map(|(v, _)| v)
Expand Down

0 comments on commit 4d6e866

Please sign in to comment.