Skip to content

Commit

Permalink
style: name change from pos to cur
Browse files Browse the repository at this point in the history
  • Loading branch information
wolkykim committed Aug 18, 2023
1 parent 3b4a2c7 commit f9a8718
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tm2/pkg/store/cache/memiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type memIterator struct {
start, end []byte
items []*std.KVPair
ascending bool
pos int
cur int
}

func newMemIterator(start, end []byte, items *list.List, ascending bool) *memIterator {
Expand All @@ -32,17 +32,17 @@ func newMemIterator(start, end []byte, items *list.List, ascending bool) *memIte
entered = true
}

pos := 0
cur := 0
if !ascending {
pos = len(itemsInDomain) - 1
cur = len(itemsInDomain) - 1
}

return &memIterator{
start: start,
end: end,
items: itemsInDomain,
ascending: ascending,
pos: pos,
cur: cur,
}
}

Expand All @@ -51,7 +51,7 @@ func (mi *memIterator) Domain() ([]byte, []byte) {
}

func (mi *memIterator) Valid() bool {
if mi.pos < 0 || len(mi.items) <= mi.pos {
if mi.cur < 0 || len(mi.items) <= mi.cur {
return false
}
return true
Expand All @@ -66,20 +66,20 @@ func (mi *memIterator) assertValid() {
func (mi *memIterator) Next() {
mi.assertValid()
if mi.ascending {
mi.pos++
mi.cur++
} else {
mi.pos--
mi.cur--
}
}

func (mi *memIterator) Key() []byte {
mi.assertValid()
return mi.items[mi.pos].Key
return mi.items[mi.cur].Key
}

func (mi *memIterator) Value() []byte {
mi.assertValid()
return mi.items[mi.pos].Value
return mi.items[mi.cur].Value
}

func (mi *memIterator) Close() {
Expand Down

0 comments on commit f9a8718

Please sign in to comment.