@@ -168,12 +168,12 @@ impl error::Error for PolicyError {
168168
169169#[ cfg( feature = "compiler" ) ]
170170struct TapleafProbabilityIter < ' p , Pk : MiniscriptKey > {
171- stack : Vec < ( f64 , & ' p Policy < Pk > ) > ,
171+ stack : Vec < ( PositiveF64 , & ' p Policy < Pk > ) > ,
172172}
173173
174174#[ cfg( feature = "compiler" ) ]
175175impl < ' p , Pk : MiniscriptKey > Iterator for TapleafProbabilityIter < ' p , Pk > {
176- type Item = ( f64 , & ' p Policy < Pk > ) ;
176+ type Item = ( PositiveF64 , & ' p Policy < Pk > ) ;
177177
178178 fn next ( & mut self ) -> Option < Self :: Item > {
179179 loop {
@@ -184,11 +184,11 @@ impl<'p, Pk: MiniscriptKey> Iterator for TapleafProbabilityIter<'p, Pk> {
184184 let normalized_iter =
185185 PositiveF64 :: normalized_iter ( subs. iter ( ) . map ( |x| x. 0 . into ( ) ) ) ;
186186 for ( ratio, ( _, sub) ) in normalized_iter. zip ( subs. iter ( ) ) . rev ( ) {
187- self . stack . push ( ( top_prob * f64 :: from ( ratio) , sub) ) ;
187+ self . stack . push ( ( top_prob * ratio, sub) ) ;
188188 }
189189 }
190190 Policy :: Thresh ( ref thresh) if thresh. is_or ( ) => {
191- let n64 = thresh . n ( ) as f64 ;
191+ let n64 = PositiveF64 :: n ( thresh ) ;
192192 for sub in thresh. iter ( ) . rev ( ) {
193193 self . stack . push ( ( top_prob / n64, sub) ) ;
194194 }
@@ -240,7 +240,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
240240 /// leaf-nodes to [`MAX_COMPILATION_LEAVES`].
241241 #[ cfg( feature = "compiler" ) ]
242242 fn tapleaf_probability_iter ( & self ) -> TapleafProbabilityIter < ' _ , Pk > {
243- TapleafProbabilityIter { stack : vec ! [ ( 1.0 , self ) ] }
243+ TapleafProbabilityIter { stack : vec ! [ ( PositiveF64 :: ONE , self ) ] }
244244 }
245245
246246 /// Extracts the internal_key from this policy tree.
@@ -249,7 +249,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
249249 let internal_key = self
250250 . tapleaf_probability_iter ( )
251251 . filter_map ( |( prob, ref pol) | match pol {
252- Self :: Key ( pk) => Some ( ( PositiveF64 ( prob) , pk) ) ,
252+ Self :: Key ( pk) => Some ( ( prob, pk) ) ,
253253 _ => None ,
254254 } )
255255 . max_by_key ( |( prob, _) | * prob)
@@ -302,7 +302,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
302302 continue ;
303303 }
304304 let compilation = compiler:: best_compilation :: < Pk , Tap > ( pol) ?;
305- leaf_compilations. push ( ( PositiveF64 ( prob) , compilation) ) ;
305+ leaf_compilations. push ( ( prob, compilation) ) ;
306306 }
307307 if !leaf_compilations. is_empty ( ) {
308308 let tap_tree = with_huffman_tree :: < Pk > ( leaf_compilations) ;
0 commit comments