compress/bzip2,lzw: use built-in clear to simplify code

Change-Id: I16c17e322c757c8c657364065948d7cec66a8346
GitHub-Last-Rev: 9a5104fe98
GitHub-Pull-Request: golang/go#66377
Reviewed-on: https://go-review.googlesource.com/c/go/+/572199
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
apocelipes 2024-03-18 08:56:12 +00:00 committed by Gopher Robot
parent f40bf7486b
commit af0ebdd4c1
2 changed files with 2 additions and 6 deletions

View File

@ -355,9 +355,7 @@ func (bz2 *reader) readBlock() (err error) {
repeatPower := 0
// The `C' array (used by the inverse BWT) needs to be zero initialized.
for i := range bz2.c {
bz2.c[i] = 0
}
clear(bz2.c[:])
decoded := 0 // counts the number of symbols decoded by the current tree.
for {

View File

@ -170,9 +170,7 @@ func TestReaderReset(t *testing.T) {
type devZero struct{}
func (devZero) Read(p []byte) (int, error) {
for i := range p {
p[i] = 0
}
clear(p)
return len(p), nil
}