Browse Source

refactor(event_history.go) remove the extra logic

Xiang Li 12 years ago
parent
commit
0937b4d266
1 changed files with 3 additions and 2 deletions
  1. 3 2
      store/event_history.go

+ 3 - 2
store/event_history.go

@@ -58,7 +58,8 @@ func (eh *EventHistory) scan(key string, recursive bool, index uint64) (*Event,
 		return nil, nil
 		return nil, nil
 	}
 	}
 
 
-	i := eh.Queue.Front
+	offset := index - eh.StartIndex
+	i := (eh.Queue.Front + int(offset)) % eh.Queue.Capacity
 
 
 	for {
 	for {
 		e := eh.Queue.Events[i]
 		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)
 			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
 			return e, nil
 		}
 		}