Browse Source

event.go: remove extra logic in addEvent()

Xiang Li 12 years ago
parent
commit
621cf57761
1 changed files with 4 additions and 8 deletions
  1. 4 8
      file_system/event.go

+ 4 - 8
file_system/event.go

@@ -53,17 +53,15 @@ type eventQueue struct {
 	capacity int
 	capacity int
 }
 }
 
 
-func (eq *eventQueue) insert(e *Event) bool {
+func (eq *eventQueue) insert(e *Event) {
 
 
 	eq.back = (eq.back + 1) % eq.capacity
 	eq.back = (eq.back + 1) % eq.capacity
 	eq.events[eq.back] = e
 	eq.events[eq.back] = e
 
 
 	if eq.size == eq.capacity { //dequeue
 	if eq.size == eq.capacity { //dequeue
 		eq.front = (eq.back + 1) % eq.capacity
 		eq.front = (eq.back + 1) % eq.capacity
-		return true
 	} else {
 	} else {
 		eq.size++
 		eq.size++
-		return false
 	}
 	}
 
 
 }
 }
@@ -89,11 +87,9 @@ func (eh *EventHistory) addEvent(e *Event) {
 	eh.rwl.Lock()
 	eh.rwl.Lock()
 	defer eh.rwl.Unlock()
 	defer eh.rwl.Unlock()
 
 
-	if eh.Queue.insert(e) {
-		eh.StartIndex++
-	} else {
-		eh.StartIndex = eh.Queue.events[eh.Queue.front].Index
-	}
+	eh.Queue.insert(e)
+
+	eh.StartIndex = eh.Queue.events[eh.Queue.front].Index
 }
 }
 
 
 func (eh *EventHistory) scan(prefix string, index uint64) (*Event, error) {
 func (eh *EventHistory) scan(prefix string, index uint64) (*Event, error) {