mirror of
https://github.com/golang/go
synced 2024-11-18 08:44:43 -07:00
base64: refactor encoder.Write
"nn" can never be zero for any input "p", so no check is needed. This change should improve readability a bit. LGTM=nigeltao R=golang-codereviews, bradfitz, nigeltao CC=golang-codereviews https://golang.org/cl/76610045
This commit is contained in:
parent
108a4dcd75
commit
41818f8fcc
@ -159,13 +159,11 @@ func (e *encoder) Write(p []byte) (n int, err error) {
|
||||
nn := len(e.out) / 4 * 3
|
||||
if nn > len(p) {
|
||||
nn = len(p)
|
||||
nn -= nn % 3
|
||||
}
|
||||
nn -= nn % 3
|
||||
if nn > 0 {
|
||||
e.enc.Encode(e.out[0:], p[0:nn])
|
||||
if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
e.enc.Encode(e.out[0:], p[0:nn])
|
||||
if _, e.err = e.w.Write(e.out[0 : nn/3*4]); e.err != nil {
|
||||
return n, e.err
|
||||
}
|
||||
n += nn
|
||||
p = p[nn:]
|
||||
|
Loading…
Reference in New Issue
Block a user