Skip to content

Commit 3875abb

Browse files
authored
refactor(kad): replace BTreeMap::remove(Iter::next_back) with pop_last
Refactor according to note: https://github.com/libp2p/rust-libp2p/blob/1206fef09885d024323479d0383c37c4fe281c7c/protocols/kad/src/behaviour.rs#L2483-L2489 since rust-lang/rust#62924 has been stabilized. Pull-Request: #5977.
1 parent 0c2ea7c commit 3875abb

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

protocols/kad/src/behaviour.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,11 +2481,7 @@ where
24812481
let distance = source_key.distance(&target_key);
24822482
cache_candidates.insert(distance, source);
24832483
if cache_candidates.len() > max_peers as usize {
2484-
// TODO: `pop_last()` would be nice once stabilised.
2485-
// See https://github.com/rust-lang/rust/issues/62924.
2486-
let last =
2487-
*cache_candidates.keys().next_back().expect("len > 0");
2488-
cache_candidates.remove(&last);
2484+
cache_candidates.pop_last();
24892485
}
24902486
}
24912487
}

0 commit comments

Comments
 (0)