Skip to content

Commit

Permalink
adt: fast path Stab in empty interval tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Vetoshkin committed Oct 6, 2016
1 parent fa1e281 commit eae70c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/adt/interval_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ func (ivt *IntervalTree) Contains(iv Interval) bool {

// Stab returns a slice with all elements in the tree intersecting the interval.
func (ivt *IntervalTree) Stab(iv Interval) (ivs []*IntervalValue) {
if ivt.count == 0 {
return nil
}
f := func(n *IntervalValue) bool { ivs = append(ivs, n); return true }
ivt.Visit(iv, f)
return ivs
Expand Down

0 comments on commit eae70c9

Please sign in to comment.