skip add for zero

This commit is contained in:
ston1th 2022-10-08 20:39:31 +02:00
commit fd035148bb

View file

@ -84,7 +84,9 @@ func (r *Rate) SetReader(reader io.Reader) {
func (r *Rate) Read(b []byte) (n int, err error) {
n, err = r.r.Read(b)
atomic.AddInt64(&r.num, int64(n))
if n > 0 {
atomic.AddInt64(&r.num, int64(n))
}
return
}