diff --git a/pool.go b/pool.go index 03c1ae5..cc0c7d9 100644 --- a/pool.go +++ b/pool.go @@ -89,9 +89,8 @@ func (p *Pool) periodicallyPurge() { p.lock.Lock() idleWorkers := p.workers n := len(idleWorkers) - i := 0 - for i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration { - i++ + var i int + for i = 0; i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration; i++ { } expiredWorkers = append(expiredWorkers[:0], idleWorkers[:i]...) if i > 0 { diff --git a/pool_func.go b/pool_func.go index 7567db3..6a862e0 100644 --- a/pool_func.go +++ b/pool_func.go @@ -92,9 +92,8 @@ func (p *PoolWithFunc) periodicallyPurge() { p.lock.Lock() idleWorkers := p.workers n := len(idleWorkers) - i := 0 - for i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration { - i++ + var i int + for i = 0; i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration; i++ { } expiredWorkers = append(expiredWorkers[:0], idleWorkers[:i]...) if i > 0 {