From 0937b4d2668f3d2a70d27a5cda8ee1158f5e172b Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 21 Dec 2013 19:29:05 +0800 Subject: [PATCH] refactor(event_history.go) remove the extra logic --- store/event_history.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/store/event_history.go b/store/event_history.go index cb3ab49c2..02afb941c 100644 --- a/store/event_history.go +++ b/store/event_history.go @@ -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 }