Skip to content

Commit 3d9809d

Browse files
flubmatheus23
andauthored
Use cmp::Reverse instead of manual cmp
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
1 parent e2ba685 commit 3d9809d

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

noq-proto/src/connection/spaces.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,8 @@ impl PendingNewCids {
705705
/// Inserts an issued CID into the queue.
706706
pub(super) fn push(&mut self, cid: IssuedCid) {
707707
self.0.push(cid);
708-
self.0.sort_by(|a, b| match a.path_id.cmp(&b.path_id) {
709-
cmp::Ordering::Less => cmp::Ordering::Greater,
710-
cmp::Ordering::Equal => match a.sequence.cmp(&b.sequence) {
711-
cmp::Ordering::Less => cmp::Ordering::Greater,
712-
cmp::Ordering::Equal => cmp::Ordering::Equal,
713-
cmp::Ordering::Greater => cmp::Ordering::Less,
714-
},
715-
cmp::Ordering::Greater => cmp::Ordering::Less,
716-
});
708+
self.0
709+
.sort_by_key(|cid| cmp::Reverse((cid.path_id, cid.sequence)));
717710
}
718711

719712
/// Pops the next issued CID to transmit from the queue.

0 commit comments

Comments
 (0)