瀏覽代碼

optimization (#221)

xuezonggui 4 年之前
父節點
當前提交
bed494d904
共有 1 個文件被更改,包括 1 次插入2 次删除
  1. 1 2
      core/collection/rollingwindow.go

+ 1 - 2
core/collection/rollingwindow.go

@@ -79,6 +79,7 @@ func (rw *RollingWindow) updateOffset() {
 		// reset expired buckets
 		start := offset + 1
 		steps := start + span
+		offset = (offset + span) % rw.size
 		var remainder int
 		if steps > rw.size {
 			remainder = steps - rw.size
@@ -86,11 +87,9 @@ func (rw *RollingWindow) updateOffset() {
 		}
 		for i := start; i < steps; i++ {
 			rw.win.resetBucket(i)
-			offset = i
 		}
 		for i := 0; i < remainder; i++ {
 			rw.win.resetBucket(i)
-			offset = i
 		}
 		rw.offset = offset
 		rw.lastTime = timex.Now()