mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
refactor(event_history.go) remove the extra logic
This commit is contained in:
parent
ef988020b7
commit
0937b4d266
@ -58,7 +58,8 @@ func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event,
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
i := eh.Queue.Front
|
||||
offset := index - eh.StartIndex
|
||||
i := (eh.Queue.Front + int(offset)) % eh.Queue.Capacity
|
||||
|
||||
for {
|
||||
e := eh.Queue.Events[i]
|
||||
@ -75,7 +76,7 @@ func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event,
|
||||
ok = ok || strings.HasPrefix(e.Node.Key, key)
|
||||
}
|
||||
|
||||
if ok && index <= e.Index() { // make sure we bypass the smaller one
|
||||
if ok {
|
||||
return e, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user