@@ -4622,7 +4622,7 @@ tsk_tree_seek_index(tsk_tree_t *self, tsk_size_t index, tsk_flags_t TSK_UNUSED(o
4622
4622
}
4623
4623
}
4624
4624
4625
- self -> index = index ;
4625
+ self -> index = ( tsk_id_t ) index ;
4626
4626
self -> interval .left = left ;
4627
4627
if (index < self -> tree_sequence -> num_trees - 1 ) {
4628
4628
self -> interval .right = tree_index .tree_left [index + 1 ];
@@ -4631,54 +4631,63 @@ tsk_tree_seek_index(tsk_tree_t *self, tsk_size_t index, tsk_flags_t TSK_UNUSED(o
4631
4631
}
4632
4632
4633
4633
/* nervous about the following */
4634
- self -> left_index = tree_index .edge_insertion_index [index ];
4635
- self -> right_index = tree_index .edge_removal_index [index ];
4634
+ self -> left_index = ( tsk_id_t ) tree_index .edge_insertion_index [index ];
4635
+ self -> right_index = ( tsk_id_t ) tree_index .edge_removal_index [index ];
4636
4636
4637
4637
out :
4638
4638
return ret ;
4639
4639
}
4640
4640
4641
+ /*FIXME: this has been gutted to a fully naive implementation*/
4641
4642
int TSK_WARN_UNUSED
4642
- tsk_tree_seek (tsk_tree_t * self , double x , tsk_flags_t TSK_UNUSED ( options ) )
4643
+ tsk_tree_seek (tsk_tree_t * self , double x , tsk_flags_t options )
4643
4644
{
4644
4645
int ret = 0 ;
4645
4646
const double L = tsk_treeseq_get_sequence_length (self -> tree_sequence );
4646
- const double t_l = self -> interval .left ;
4647
- const double t_r = self -> interval .right ;
4648
- double distance_left , distance_right ;
4649
-
4647
+ // const double t_l = self->interval.left;
4648
+ // const double t_r = self->interval.right;
4649
+ const double * restrict left = self -> tree_sequence -> tree_index .tree_left ;
4650
+ // double distance_left, distance_right;
4651
+ tsk_size_t i ;
4650
4652
if (x < 0 || x >= L ) {
4651
4653
ret = TSK_ERR_SEEK_OUT_OF_BOUNDS ;
4652
4654
goto out ;
4653
4655
}
4654
4656
4655
- if (x < t_l ) {
4656
- /* |-----|-----|========|---------| */
4657
- /* 0 x t_l t_r L */
4658
- distance_left = t_l - x ;
4659
- distance_right = L - t_r + x ;
4660
- } else {
4661
- /* |------|========|------|-------| */
4662
- /* 0 t_l t_r x L */
4663
- distance_right = x - t_r ;
4664
- distance_left = t_l + L - x ;
4665
- }
4666
- if (distance_right <= distance_left ) {
4667
- while (!tsk_tree_position_in_interval (self , x )) {
4668
- ret = tsk_tree_next (self );
4669
- if (ret < 0 ) {
4670
- goto out ;
4671
- }
4672
- }
4673
- } else {
4674
- while (!tsk_tree_position_in_interval (self , x )) {
4675
- ret = tsk_tree_prev (self );
4676
- if (ret < 0 ) {
4677
- goto out ;
4678
- }
4657
+ for (i = 0 ; i < self -> tree_sequence -> num_trees ; ++ i ) {
4658
+ if (x >= left [i ]) {
4659
+ break ;
4679
4660
}
4680
4661
}
4681
- ret = 0 ;
4662
+ ret = tsk_tree_seek_index (self , i , options );
4663
+
4664
+ // if (x < t_l) {
4665
+ // /* |-----|-----|========|---------| */
4666
+ // /* 0 x t_l t_r L */
4667
+ // distance_left = t_l - x;
4668
+ // distance_right = L - t_r + x;
4669
+ //} else {
4670
+ // /* |------|========|------|-------| */
4671
+ // /* 0 t_l t_r x L */
4672
+ // distance_right = x - t_r;
4673
+ // distance_left = t_l + L - x;
4674
+ //}
4675
+ // if (distance_right <= distance_left) {
4676
+ // while (!tsk_tree_position_in_interval(self, x)) {
4677
+ // ret = tsk_tree_next(self);
4678
+ // if (ret < 0) {
4679
+ // goto out;
4680
+ // }
4681
+ // }
4682
+ //} else {
4683
+ // while (!tsk_tree_position_in_interval(self, x)) {
4684
+ // ret = tsk_tree_prev(self);
4685
+ // if (ret < 0) {
4686
+ // goto out;
4687
+ // }
4688
+ // }
4689
+ //}
4690
+ // ret = 0;
4682
4691
out :
4683
4692
return ret ;
4684
4693
}
0 commit comments