Performance improvement when writing formatted strings

This commit is contained in:
Manu Mtz-Almeida 2015-04-07 19:54:17 +02:00
parent 1f6304ca25
commit d33079d0ec
1 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ func (_ plainTextRender) Render(w http.ResponseWriter, code int, data ...interfa
format := data[0].(string) format := data[0].(string)
args := data[1].([]interface{}) args := data[1].([]interface{})
if len(args) > 0 { if len(args) > 0 {
_, err = w.Write([]byte(fmt.Sprintf(format, args...))) _, err = fmt.Fprintf(w, format, args...)
} else { } else {
_, err = w.Write([]byte(format)) _, err = w.Write([]byte(format))
} }
@ -86,7 +86,7 @@ func (_ htmlPlainRender) Render(w http.ResponseWriter, code int, data ...interfa
format := data[0].(string) format := data[0].(string)
args := data[1].([]interface{}) args := data[1].([]interface{})
if len(args) > 0 { if len(args) > 0 {
_, err = w.Write([]byte(fmt.Sprintf(format, args...))) _, err = fmt.Fprintf(w, format, args...)
} else { } else {
_, err = w.Write([]byte(format)) _, err = w.Write([]byte(format))
} }