Skip to content

Commit

Permalink
refactor: remove dead code in cacheMergeIterator Domain() (#13433)
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica authored Oct 5, 2022
1 parent facac1c commit 87e46b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#13168](https://github.com/cosmos/cosmos-sdk/pull/13168) Migrate tendermintdev/proto-builder to ghcr.io. New image `ghcr.io/cosmos/proto-builder:0.8`
* [#13178](https://github.com/cosmos/cosmos-sdk/pull/13178) Add `cosmos.msg.v1.service` protobuf annotation to allow tooling to distinguish between Msg and Query services via reflection.
* [#13236](https://github.com/cosmos/cosmos-sdk/pull/13236) Integrate Filter Logging
* [#13433](https://github.com/cosmos/cosmos-sdk/pull/13433) Remove dead code in cacheMergeIterator `Domain()`.

### State Machine Breaking

Expand Down
11 changes: 6 additions & 5 deletions store/cachekv/memiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ type memIterator struct {
}

func newMemIterator(start, end []byte, items *dbm.MemDB, deleted map[string]struct{}, ascending bool) *memIterator {
var iter types.Iterator
var err error
var (
iter types.Iterator
err error
)

if ascending {
iter, err = items.Iterator(start, end)
Expand All @@ -34,9 +36,8 @@ func newMemIterator(start, end []byte, items *dbm.MemDB, deleted map[string]stru

return &memIterator{
Iterator: iter,

lastKey: nil,
deleted: deleted,
lastKey: nil,
deleted: deleted,
}
}

Expand Down
19 changes: 2 additions & 17 deletions store/cachekv/mergeiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,9 @@ func newCacheMergeIterator(parent, cache types.Iterator, ascending bool) *cacheM
}

// Domain implements Iterator.
// If the domains are different, returns the union.
// Returns parent domain because cache and parent domains are the same.
func (iter *cacheMergeIterator) Domain() (start, end []byte) {
startP, endP := iter.parent.Domain()
startC, endC := iter.cache.Domain()

if iter.compare(startP, startC) < 0 {
start = startP
} else {
start = startC
}

if iter.compare(endP, endC) < 0 {
end = endC
} else {
end = endP
}

return start, end
return iter.parent.Domain()
}

// Valid implements Iterator.
Expand Down

0 comments on commit 87e46b2

Please sign in to comment.