소스 검색

adt: fast path Stab in empty interval tree

Nikita Vetoshkin 9 년 전
부모
커밋
eae70c9379
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      pkg/adt/interval_tree.go

+ 3 - 0
pkg/adt/interval_tree.go

@@ -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