Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove network dep from tree #13921

Merged
merged 1 commit into from
Jan 22, 2025
Merged

chore: remove network dep from tree #13921

merged 1 commit into from
Jan 22, 2025

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Jan 22, 2025

gets rid of the network dep by inlining the only function we need

/// Same as [`insert`](Self::insert) but returns a tuple, where the second index is the evicted
/// value, if one was evicted.
pub fn insert_and_get_evicted(&mut self, entry: T) -> (bool, Option<T>) {
let new = self.inner.peek(&entry).is_none();
let evicted =
(new && (self.limit as usize) <= self.inner.len()).then(|| self.remove_lru()).flatten();
_ = self.inner.get_or_insert(entry, || ());
(new, evicted)
}

@mattsse mattsse added the C-debt Refactor of code section that is hard to understand or maintain label Jan 22, 2025
@mattsse mattsse added this pull request to the merge queue Jan 22, 2025
Merged via the queue into main with commit 66fb8c8 Jan 22, 2025
44 checks passed
@mattsse mattsse deleted the matt/remove-network-dep branch January 22, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants