From e2459e627f1a06bf035ded92b5170fd20d17ca22 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Wed, 6 Mar 2024 17:07:48 +0000 Subject: [PATCH] encoding/binary: use built-in clear to simplify code Change-Id: I2f3c7f4a4848ad0fbbf79bd8919b1e2abee72f3f GitHub-Last-Rev: 06d0047b28fe1c8c87f84aca049b8c76778732b9 GitHub-Pull-Request: golang/go#66136 Reviewed-on: https://go-review.googlesource.com/c/go/+/569280 Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek --- src/encoding/binary/binary.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/encoding/binary/binary.go b/src/encoding/binary/binary.go index f001be83861..59a6c654d2a 100644 --- a/src/encoding/binary/binary.go +++ b/src/encoding/binary/binary.go @@ -765,10 +765,7 @@ func (d *decoder) skip(v reflect.Value) { func (e *encoder) skip(v reflect.Value) { n := dataSize(v) - zero := e.buf[e.offset : e.offset+n] - for i := range zero { - zero[i] = 0 - } + clear(e.buf[e.offset : e.offset+n]) e.offset += n }