Change-Id: Id34936a115baaf61e4268582c6d9a2027494c385
GitHub-Last-Rev:
5fe455b7d24e3e3b871c8999c5bb534f3e1e3ab5
GitHub-Pull-Request: golang/go#66244
Reviewed-on: https://go-review.googlesource.com/c/go/+/570555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
// Recycle the quantization error buffers.
if floydSteinberg {
quantErrorCurr, quantErrorNext = quantErrorNext, quantErrorCurr
- for i := range quantErrorNext {
- quantErrorNext[i] = [4]int32{}
- }
+ clear(quantErrorNext)
}
}
}
// seem OK with this, so we enlarge the palette with
// transparent colors. See golang.org/issue/15059.
p := make(color.Palette, ti+1)
- copy(p, m.Palette)
- for i := len(m.Palette); i < len(p); i++ {
- p[i] = color.RGBA{}
- }
+ i := copy(p, m.Palette)
+ clear(p[i:])
m.Palette = p
}
}
n := log2Lookup[size]
if n > len(p) {
// Pad with black.
- fill := dst[3*len(p) : 3*n]
- for i := range fill {
- fill[i] = 0
- }
+ clear(dst[3*len(p) : 3*n])
}
return 3 * n, nil
}
}
// Derive the look-up table.
- for i := range h.lut {
- h.lut[i] = 0
- }
+ clear(h.lut[:])
var x, code uint32
for i := uint32(0); i < lutSize; i++ {
code <<= 1
return filter
}
-func zeroMemory(v []uint8) {
- for i := range v {
- v[i] = 0
- }
-}
-
func (e *encoder) writeImage(w io.Writer, m image.Image, cb int, level int) error {
if e.zw == nil || e.zwLevel != level {
zw, err := zlib.NewWriterLevel(w, level)
e.pr = make([]uint8, sz)
} else {
e.pr = e.pr[:sz]
- zeroMemory(e.pr)
+ clear(e.pr)
}
pr := e.pr