mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
adt: fast path Stab in empty interval tree
This commit is contained in:
parent
fa1e28102e
commit
eae70c9379
@ -447,6 +447,9 @@ func (ivt *IntervalTree) Contains(iv Interval) bool {
|
|||||||
|
|
||||||
// Stab returns a slice with all elements in the tree intersecting the interval.
|
// Stab returns a slice with all elements in the tree intersecting the interval.
|
||||||
func (ivt *IntervalTree) Stab(iv Interval) (ivs []*IntervalValue) {
|
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 }
|
f := func(n *IntervalValue) bool { ivs = append(ivs, n); return true }
|
||||||
ivt.Visit(iv, f)
|
ivt.Visit(iv, f)
|
||||||
return ivs
|
return ivs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user