Skip to content

Commit

Permalink
Tiny speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Oct 17, 2024
1 parent 03d78a8 commit db8a197
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/btreemap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ where
}
}

fn ensure_cursors_initialized(&mut self) {
if self.cursors_initialized {
return;
}
fn initialize_cursors(&mut self) {
debug_assert!(!self.cursors_initialized);

match self.range.start_bound() {
Bound::Unbounded => {
Expand Down Expand Up @@ -185,7 +183,9 @@ where
// Iterates to find the next element in the requested range.
// If it exists, `map` is applied to that element and the result is returned.
fn next_map<T, F: Fn(&Node<K>, usize) -> T>(&mut self, map: F) -> Option<T> {
self.ensure_cursors_initialized();
if !self.cursors_initialized {
self.initialize_cursors();
}

// If the cursors are empty. Iteration is complete.
match self.cursors.pop()? {
Expand Down

0 comments on commit db8a197

Please sign in to comment.