Skip to content

Commit cef9d46

Browse files
committed
Use BTreeMap internally
The `BTreeMap` is a drop in replacement for the `HashMap` with the benefit that it is available in no-std environments. We have a few uses of `HashMap`s internally within functions, we can use `BTreeMap` instead. Done in preparation for removing the `hashbrown` dependency.
1 parent 4e2ee86 commit cef9d46

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/policy/concrete.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
327327
let mut prob = 0.;
328328
let semantic_policy = self.lift()?;
329329
let concrete_keys = self.keys();
330-
let key_prob_map: HashMap<_, _> = self
330+
let key_prob_map: BTreeMap<_, _> = self
331331
.to_tapleaf_prob_vec(1.0)
332332
.into_iter()
333333
.filter(|(_, ref pol)| matches!(*pol, Concrete::Key(..)))
@@ -347,7 +347,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
347347
internal_key = Some(key.clone());
348348
}
349349
}
350-
None => return Err(errstr("Key should have existed in the HashMap!")),
350+
None => return Err(errstr("Key should have existed in the BTreeMap!")),
351351
}
352352
}
353353
}
@@ -563,7 +563,7 @@ impl<Pk: MiniscriptKey> PolicyArc<Pk> {
563563
// owing to the current [policy element enumeration algorithm][`Policy::enumerate_pol`],
564564
// two passes of the algorithm might result in same sub-policy showing up. Currently, we
565565
// merge the nodes by adding up the corresponding probabilities for the same policy.
566-
let mut pol_prob_map = HashMap::<Arc<Self>, OrdF64>::new();
566+
let mut pol_prob_map = BTreeMap::<Arc<Self>, OrdF64>::new();
567567

568568
let arc_self = Arc::new(self);
569569
tapleaf_prob_vec.insert((Reverse(OrdF64(prob)), Arc::clone(&arc_self)));

0 commit comments

Comments
 (0)