mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-22 01:34:18 +00:00
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>
This commit is contained in:
parent
59fd641d1f
commit
f0e15250b9
77 changed files with 264 additions and 82 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue