From ad670bab6819fb8e6f8f4c6e8b99b1ba663b8945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= <i@sekai.icu> Date: Sat, 9 Dec 2023 23:43:36 +0800 Subject: [PATCH] Improve WriteZeroN using `clear` in go1.21 --- common/buf/buffer.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 3315f45..26c6c74 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -216,10 +216,7 @@ func (b *Buffer) WriteZeroN(n int) error { if b.end+n > b.capacity { return io.ErrShortBuffer } - for i := b.end; i < b.end+n; i++ { - b.data[i] = 0 - } - b.end += n + common.ClearArray(b.Extend(n)) return nil }