Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce allocs and improve the render WriteString #2508

Merged
merged 4 commits into from Oct 16, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}