Skip to content

Commit a3338fb

Browse files
committed
policy: use new tapleaf_probability_iter for num_tap_leaves
1 parent 3522703 commit a3338fb

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

src/policy/concrete.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -578,23 +578,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
578578
/// Gets the number of [TapLeaf](`TapTree::Leaf`)s considering exhaustive root-level [`Policy::Or`]
579579
/// and [`Policy::Thresh`] disjunctions for the `TapTree`.
580580
#[cfg(feature = "compiler")]
581-
fn num_tap_leaves(&self) -> usize {
582-
use Policy::*;
583-
584-
let mut nums = vec![];
585-
for data in self.rtl_post_order_iter() {
586-
let num = match data.node {
587-
Or(subs) => (0..subs.len()).map(|_| nums.pop().unwrap()).sum(),
588-
Thresh(thresh) if thresh.is_or() => {
589-
(0..thresh.n()).map(|_| nums.pop().unwrap()).sum()
590-
}
591-
_ => 1,
592-
};
593-
nums.push(num);
594-
}
595-
// Ok to unwrap because we know we processed at least one node.
596-
nums.pop().unwrap()
597-
}
581+
fn num_tap_leaves(&self) -> usize { self.tapleaf_probability_iter().count() }
598582

599583
/// Does checks on the number of `TapLeaf`s.
600584
#[cfg(feature = "compiler")]

0 commit comments

Comments
 (0)