Skip to content

Commit

Permalink
fix btree len to height
Browse files Browse the repository at this point in the history
Height is thread safe and Len isn’t.
  • Loading branch information
fredcarle committed Dec 19, 2022
1 parent 4df2b24 commit 829ad47
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datastore/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err erro

// Query implements ds.Query
func (d *Datastore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error) {
re := make([]dsq.Entry, 0, d.values.Len())
re := make([]dsq.Entry, 0, d.values.Height())
iter := d.values.Iter()
for iter.Next() {
// fast forward to last inserted version
Expand Down
2 changes: 1 addition & 1 deletion datastore/memory/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (t *basicTxn) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)
return nil, ErrTxnDiscarded
}
// best effort allocation
re := make([]dsq.Entry, 0, t.ds.values.Len()+t.ops.Len())
re := make([]dsq.Entry, 0, t.ds.values.Height()+t.ops.Height())
iter := t.ds.values.Iter()
iterOps := t.ops.Iter()
iterOpsHasValue := iterOps.Next()
Expand Down

0 comments on commit 829ad47

Please sign in to comment.