@@ -335,12 +335,13 @@ where
335335 }
336336 }
337337
338+ let mut max_data_len = 0 ;
338339 const DATA_SIZE : usize = 50000 ;
339340 loop {
340341 let current_start = self . next_start ;
341342 self . next_start = current_start + DATA_SIZE as u32 ;
342343
343- let mut data = vec ! [ 0f32 ; DATA_SIZE ] ;
344+ let mut data = vec ! [ 0f64 ; DATA_SIZE ] ;
344345 let mut max_sections: usize = 0 ;
345346 let mut all_none = true ;
346347 ' sections: for ( section, last) in & mut self . sections {
@@ -366,8 +367,9 @@ where
366367 let data_end = DATA_SIZE . min ( ( next_val. end - current_start) as usize ) ;
367368 let value = next_val. value ;
368369 for i in & mut data[ data_start..data_end] {
369- * i += value
370+ * i += value as f64
370371 }
372+ max_data_len = max_data_len. max ( data_end) ;
371373 max_sections += 1 ;
372374 if ( next_val. end - current_start) as usize >= DATA_SIZE {
373375 * last = Some ( next_val) ;
@@ -378,30 +380,31 @@ where
378380
379381 // TODO: coverage so can take average, or 'real' zeros
380382 let mut next_sections: Vec < Value > = Vec :: with_capacity ( max_sections * 2 ) ;
381- let mut current: Option < ( u32 , u32 , f32 ) > = None ;
382- for ( idx, i) in data[ ..] . iter ( ) . enumerate ( ) {
383+ let mut current: Option < ( u32 , u32 , f64 ) > = None ;
384+ for ( idx, i) in data[ ..max_data_len] . iter ( ) . enumerate ( ) {
385+ let idx = idx as u32 ;
383386 match & mut current {
384387 None => {
385388 current = Some ( (
386- idx as u32 + current_start,
387- idx as u32 + current_start + 1 ,
389+ idx + current_start,
390+ idx + current_start + 1 ,
388391 * i,
389392 ) )
390393 }
391394 Some ( c) => {
392- if ( c. 2 - * i) . abs ( ) < std :: f32 :: EPSILON {
395+ if c. 2 == * i {
393396 c. 1 += 1 ;
394397 } else {
395398 if c. 2 != 0.0 {
396399 next_sections. push ( Value {
397400 start : c. 0 ,
398401 end : c. 1 ,
399- value : c. 2 ,
402+ value : c. 2 as f32 ,
400403 } ) ;
401404 }
402405 current = Some ( (
403- idx as u32 + current_start,
404- idx as u32 + current_start + 1 ,
406+ idx + current_start,
407+ idx + current_start + 1 ,
405408 * i,
406409 ) ) ;
407410 }
@@ -413,7 +416,7 @@ where
413416 next_sections. push ( Value {
414417 start : c. 0 ,
415418 end : c. 1 ,
416- value : c. 2 ,
419+ value : c. 2 as f32 ,
417420 } ) ;
418421 }
419422 }
0 commit comments