diff --git a/cache.go b/cache.go index 8156c16d..3c6ee786 100644 --- a/cache.go +++ b/cache.go @@ -166,3 +166,14 @@ func (c *clientCache) behaviorScoreLocked(state *clientState, paths []string) in return 0 } +func (c *clientCache) pruneEventsLocked(state *clientState, now time.Time) { + cutoff := now.Add(-c.scoreWindow) + first := 0 + for first < len(state.events) && !state.events[first].at.After(cutoff) { + first++ + } + if first > 0 { + state.events = append([]scoreEvent(nil), state.events[first:]...) + } +} +