diff options
author | zeripath <art27@cantab.net> | 2021-03-01 21:08:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 22:08:10 +0100 |
commit | f0e15250b9e322cc7731ba026d12387c2b549a42 (patch) | |
tree | f13d46119077ba924d620ef172b91daa315bda0a /modules/templates | |
parent | 59fd641d1fb021e35aea7f9f4a1916cc11ef5c51 (diff) | |
download | gitea-f0e15250b9e322cc7731ba026d12387c2b549a42.tar.gz gitea-f0e15250b9e322cc7731ba026d12387c2b549a42.zip |
Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter
* fix tests
* update gitea.com/go-chi/binding
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/templates')
-rw-r--r-- | modules/templates/helper.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 4b9b648b2f..d3f6b8e06f 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -38,6 +38,7 @@ import ( mirror_service "code.gitea.io/gitea/services/mirror" "github.com/editorconfig/editorconfig-core-go/v2" + jsoniter "github.com/json-iterator/go" ) // Used from static.go && dynamic.go @@ -45,6 +46,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`) // NewFuncMap returns functions for injecting to templates func NewFuncMap() []template.FuncMap { + jsonED := jsoniter.ConfigCompatibleWithStandardLibrary return []template.FuncMap{map[string]interface{}{ "GoVer": func() string { return strings.Title(runtime.Version()) @@ -215,7 +217,7 @@ func NewFuncMap() []template.FuncMap { return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100) }, "Json": func(in interface{}) string { - out, err := json.Marshal(in) + out, err := jsonED.Marshal(in) if err != nil { return "" } @@ -814,6 +816,8 @@ func ActionIcon(opType models.ActionType) string { // ActionContent2Commits converts action content to push commits func ActionContent2Commits(act Actioner) *repository.PushCommits { push := repository.NewPushCommits() + + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(act.GetContent()), push); err != nil { log.Error("json.Unmarshal:\n%s\nERROR: %v", act.GetContent(), err) } |