Skip to content
Myr

reduce allocs and improve the render `WriteString` (#2508)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by xyb · committed by GitHub · parent d541085 · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: yonbiaoxiao <yonbiaoxiao@tencent.com>
  • Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Co-authored-by: thinkerou <thinkerou@gmail.com>

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:render/text.go+3 added-1 removed
5 unmodified lines
67import (8 "fmt"9 "net/http"1011 "github.com/gin-gonic/gin/internal/bytesconv"12)1314// String contains the given interface object slice and its format.15type String struct {
19 unmodified lines
35 if len(data) > 0 {36 _, err = fmt.Fprintf(w, format, data...)37 return38 }37 _, err = w.Write([]byte(format))39 _, err = w.Write(bytesconv.StringToBytes(format))40 return41}