1
0
mirror of https://github.com/golang/go synced 2024-11-23 19:50:06 -07:00

Address review of Patch Set 4

This commit is contained in:
svent 2019-02-25 20:42:33 +01:00 committed by Sven Taute
parent 36e0b2d4df
commit 0e84a56944

View File

@ -373,8 +373,7 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) {
// DecodeString returns the bytes represented by the base32 string s.
func (enc *Encoding) DecodeString(s string) ([]byte, error) {
dbuf := make([]byte, enc.DecodedLen(len(s)))
src := make([]byte, len(s))
copy(src, s)
src := []byte(s)
l := stripNewlines(src)
n, _, err := enc.decode(dbuf, src[:l])
return dbuf[:n], err
@ -496,9 +495,9 @@ type newlineFilteringReader struct {
// of non-newline characters moved to the beginning of p.
func stripNewlines(p []byte) int {
offset := 0
for i, b := range p[0:len(p)] {
for i, b := range p {
if b != '\r' && b != '\n' {
if i != offset {
if i > offset {
p[offset] = b
}
offset++