simple rolling windows code (#346)

master
zjbztianya 4 years ago committed by GitHub
parent 12e235efb0
commit 7a921f66e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save