Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 888776f

Browse files
cdatakoivunej
andauthored
Update src/ipld/dag_cbor.rs
Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
1 parent 8e0d5d5 commit 888776f

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/ipld/dag_cbor.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,7 @@ impl<T: WriteCbor + 'static> WriteCbor for BTreeMap<String, T> {
325325
let mut keys: Vec<&String> = self.keys().collect();
326326

327327
// See: https://github.com/ipld/ipld/blob/master/specs/codecs/dag-cbor/spec.md#strictness
328-
keys.sort_by(|l, r| {
329-
if r.len() > l.len() {
330-
Ordering::Less
331-
} else if r.len() < l.len() {
332-
Ordering::Greater
333-
} else {
334-
l.partial_cmp(r).or(Some(Ordering::Equal)).unwrap()
335-
}
336-
});
328+
keys.sort_by(|l, r| l.len().cmp(&r.len()).then_with(|| l.cmp(r)));
337329

338330
for k in keys {
339331
let v = self.get(k).unwrap();

0 commit comments

Comments
 (0)