]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: use WriteString directly when possible
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 21 May 2013 02:26:26 +0000 (19:26 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 21 May 2013 02:26:26 +0000 (19:26 -0700)
Several places used io.WriteString unnecessarily when the
static type already implemented WriteString. No need to
check for it at runtime.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9608043

src/pkg/net/http/server.go

index 698d3f9d46ffc2180cafa321c795165633524a41..e0002850476502082903712443add8f43d28da0b 100644 (file)
@@ -278,7 +278,7 @@ func (cw *chunkWriter) close() {
                // zero EOF chunk, trailer key/value pairs (currently
                // unsupported in Go's server), followed by a blank
                // line.
-               io.WriteString(cw.res.conn.buf, "0\r\n\r\n")
+               cw.res.conn.buf.WriteString("0\r\n\r\n")
        }
 }
 
@@ -512,7 +512,7 @@ func (ecr *expectContinueReader) Read(p []byte) (n int, err error) {
        }
        if !ecr.resp.wroteContinue && !ecr.resp.conn.hijacked() {
                ecr.resp.wroteContinue = true
-               io.WriteString(ecr.resp.conn.buf, "HTTP/1.1 100 Continue\r\n\r\n")
+               ecr.resp.conn.buf.WriteString("HTTP/1.1 100 Continue\r\n\r\n")
                ecr.resp.conn.buf.Flush()
        }
        return ecr.readCloser.Read(p)
@@ -847,7 +847,7 @@ func (cw *chunkWriter) writeHeader(p []byte) {
                setHeader.connection = "close"
        }
 
-       io.WriteString(w.conn.buf, statusLine(w.req, code))
+       w.conn.buf.WriteString(statusLine(w.req, code))
        cw.header.WriteSubset(w.conn.buf, excludeHeader)
        setHeader.Write(w.conn.buf.Writer)
        w.conn.buf.Write(crlf)