Commit 74fc8bb8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0700f488
...@@ -513,10 +513,10 @@ type rangeSplit []*nodeInRange // key↑ ...@@ -513,10 +513,10 @@ type rangeSplit []*nodeInRange // key↑
// Get panics if k is not covered. // Get panics if k is not covered.
func (rs rangeSplit) Get(k Key) *nodeInRange { func (rs rangeSplit) Get(k Key) *nodeInRange {
rnode, ok := rs.Get_(k) rnode, ok := rs.Get_(k)
if ok { if !ok {
return rnode panicf("key %v not covered", k)
} }
panicf("key %v not covered", k) return rnode
} }
// Get_ returns node covering key k. // Get_ returns node covering key k.
...@@ -528,12 +528,12 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) { ...@@ -528,12 +528,12 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
return nil, false // key not covered return nil, false // key not covered
} }
rn = rs[i] rn := rs[i]
if !(rn.lo <= k && k <= rn.hi_) { if !(rn.lo <= k && k <= rn.hi_) {
panicf("BUG: get(%v) -> %s", k, rn) panicf("BUG: get(%v) -> %s", k, rn)
} }
return rn return rn, true
} }
// Expand replaces rnode with its children. // Expand replaces rnode with its children.
...@@ -558,7 +558,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) { ...@@ -558,7 +558,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
// [len(ev)].Key = +∞ ; should be assumed so // [len(ev)].Key = +∞ ; should be assumed so
tree := rnode.node.(*Tree) tree := rnode.node.(*Tree)
treev := tree.Entryv() treev := tree.Entryv()
children := make(rangeSplit, 0, len(treev)+1) children = make(rangeSplit, 0, len(treev)+1)
for i := range treev { for i := range treev {
lo := rnode.lo lo := rnode.lo
if i > 0 { if i > 0 {
...@@ -580,7 +580,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) { ...@@ -580,7 +580,7 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
// GetToBucket returns bucket corresponding to key k. // GetToBucket returns bucket corresponding to key k.
// While reaching to that bucket, it expands step-by-step trees that are leading to that bucket. // While reaching to that bucket, it expands step-by-step trees that are leading to that bucket.
// XXX also return path? // XXX also return path?
func (prs *rangeSplit) GetToBucket(ctx, k) (rbucket *nodeInRange, bool ok, err error) { func (prs *rangeSplit) GetToBucket(ctx context.Context, k Key) (rbucket *nodeInRange, ok bool, err error) {
rnode, ok := prs.Get_(k) rnode, ok := prs.Get_(k)
if !ok { if !ok {
return nil, false, nil // key not covered return nil, false, nil // key not covered
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment