Browse Source

Use slice instead of array in base64Wrap.

Looks like I was going a little overboard, and not getting any more
speed for the trouble.
Jed Denlea 11 years ago
parent
commit
7d362f33ad
1 changed files with 3 additions and 3 deletions
  1. 3 3
      email.go

+ 3 - 3
email.go

@@ -285,12 +285,12 @@ func base64Wrap(w io.Writer, b []byte) {
 	// 57 raw bytes per 76-byte base64 line.
 	const maxRaw = 57
 	// Buffer for each line, including trailing CRLF.
-	var buffer [MaxLineLength + len("\r\n")]byte
+	buffer := make([]byte, MaxLineLength + len("\r\n"))
 	copy(buffer[MaxLineLength:], "\r\n")
 	// Process raw chunks until there's no longer enough to fill a line.
 	for len(b) >= maxRaw {
-		base64.StdEncoding.Encode(buffer[:], b[:maxRaw])
-		w.Write(buffer[:])
+		base64.StdEncoding.Encode(buffer, b[:maxRaw])
+		w.Write(buffer)
 		b = b[maxRaw:]
 	}
 	// Handle the last chunk of bytes.