mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08: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:
		@@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user