Skip to content

Commit

Permalink
optimization (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonoT authored Nov 28, 2020
1 parent 2dfecda commit bed494d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions core/collection/rollingwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,17 @@ 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
steps = rw.size
}
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()
Expand Down

0 comments on commit bed494d

Please sign in to comment.