Skip to content

Commit

Permalink
Merge pull request etcd-io#6601 from nekto0n/interval_tree_fast_stab
Browse files Browse the repository at this point in the history
adt: fast path Stab in empty interval tree
  • Loading branch information
xiang90 authored Oct 7, 2016
2 parents f3cdfcd + eae70c9 commit e2bd6f2
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 e2bd6f2

Please sign in to comment.