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 /models/repo_unit.go | |
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 'models/repo_unit.go')
-rw-r--r-- | models/repo_unit.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/models/repo_unit.go b/models/repo_unit.go index 8c2d458758..3ef3904833 100644 --- a/models/repo_unit.go +++ b/models/repo_unit.go @@ -5,11 +5,11 @@ package models import ( - "encoding/json" "fmt" "code.gitea.io/gitea/modules/timeutil" + jsoniter "github.com/json-iterator/go" "xorm.io/xorm" "xorm.io/xorm/convert" ) @@ -29,11 +29,13 @@ type UnitConfig struct { // FromDB fills up a UnitConfig from serialized format. func (cfg *UnitConfig) FromDB(bs []byte) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Unmarshal(bs, &cfg) } // ToDB exports a UnitConfig to a serialized format. func (cfg *UnitConfig) ToDB() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Marshal(cfg) } @@ -44,11 +46,13 @@ type ExternalWikiConfig struct { // FromDB fills up a ExternalWikiConfig from serialized format. func (cfg *ExternalWikiConfig) FromDB(bs []byte) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Unmarshal(bs, &cfg) } // ToDB exports a ExternalWikiConfig to a serialized format. func (cfg *ExternalWikiConfig) ToDB() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Marshal(cfg) } @@ -61,11 +65,13 @@ type ExternalTrackerConfig struct { // FromDB fills up a ExternalTrackerConfig from serialized format. func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Unmarshal(bs, &cfg) } // ToDB exports a ExternalTrackerConfig to a serialized format. func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Marshal(cfg) } @@ -78,11 +84,13 @@ type IssuesConfig struct { // FromDB fills up a IssuesConfig from serialized format. func (cfg *IssuesConfig) FromDB(bs []byte) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Unmarshal(bs, &cfg) } // ToDB exports a IssuesConfig to a serialized format. func (cfg *IssuesConfig) ToDB() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Marshal(cfg) } @@ -97,11 +105,13 @@ type PullRequestsConfig struct { // FromDB fills up a PullRequestsConfig from serialized format. func (cfg *PullRequestsConfig) FromDB(bs []byte) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Unmarshal(bs, &cfg) } // ToDB exports a PullRequestsConfig to a serialized format. func (cfg *PullRequestsConfig) ToDB() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary return json.Marshal(cfg) } |