Skip to content

Commit

Permalink
reduce allocs and improve the render WriteString (#2508)
Browse files Browse the repository at this point in the history
Co-authored-by: yonbiaoxiao <yonbiaoxiao@tencent.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
  • Loading branch information
4 people committed Oct 16, 2020
1 parent d541085 commit c83a1cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion render/text.go
Expand Up @@ -7,6 +7,8 @@ package render
import (
"fmt"
"net/http"

"github.com/gin-gonic/gin/internal/bytesconv"
)

// String contains the given interface object slice and its format.
Expand Down Expand Up @@ -34,6 +36,6 @@ func WriteString(w http.ResponseWriter, format string, data []interface{}) (err
_, err = fmt.Fprintf(w, format, data...)
return
}
_, err = w.Write([]byte(format))
_, err = w.Write(bytesconv.StringToBytes(format))
return
}

0 comments on commit c83a1cc

Please sign in to comment.