Skip to content

Commit 9c78534

Browse files
uberhalitalecthomas
authored andcommitted
fixed EasyJSON overrides
1 parent fecb85b commit 9c78534

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

serialization_benchmarks_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
var (
3535
validate = os.Getenv("VALIDATE")
36+
jsoniterFast = jsoniter.ConfigFastest
3637
)
3738

3839
func randString(l int) string {
@@ -216,12 +217,12 @@ func BenchmarkJsonUnmarshal(b *testing.B) {
216217
type JsonIterSerializer struct{}
217218

218219
func (j JsonIterSerializer) Marshal(o interface{}) []byte {
219-
d, _ := jsoniter.Marshal(o)
220+
d, _ := jsoniterFast.Marshal(o)
220221
return d
221222
}
222223

223224
func (j JsonIterSerializer) Unmarshal(d []byte, o interface{}) error {
224-
return jsoniter.Unmarshal(d, o)
225+
return jsoniterFast.Unmarshal(d, o)
225226
}
226227

227228
func (j JsonIterSerializer) String() string {
@@ -241,12 +242,12 @@ func BenchmarkJsonIterUnmarshal(b *testing.B) {
241242
type EasyJSONSerializer struct{}
242243

243244
func (m EasyJSONSerializer) Marshal(o interface{}) []byte {
244-
out, _ := o.(*A).MarshalJSON()
245+
out, _ := o.(*A).MarshalJSONEasyJSON()
245246
return out
246247
}
247248

248249
func (m EasyJSONSerializer) Unmarshal(d []byte, o interface{}) error {
249-
err := o.(*A).UnmarshalJSON(d)
250+
err := o.(*A).UnmarshalJSONEasyJSON(d)
250251
return err
251252
}
252253

structdef_easyjson.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ func easyjson_encode_go_serialization_benchmarks_A(out *jwriter.Writer, in *A) {
8484
out.Float64(in.Money)
8585
out.RawByte('}')
8686
}
87-
func (v *A) MarshalJSON() ([]byte, error) {
87+
func (v *A) MarshalJSONEasyJSON() ([]byte, error) {
8888
w := jwriter.Writer{}
8989
easyjson_encode_go_serialization_benchmarks_A(&w, v)
9090
return w.Buffer.BuildBytes(), w.Error
9191
}
9292
func (v *A) MarshalEasyJSON(w *jwriter.Writer) {
9393
easyjson_encode_go_serialization_benchmarks_A(w, v)
9494
}
95-
func (v *A) UnmarshalJSON(data []byte) error {
95+
func (v *A) UnmarshalJSONEasyJSON(data []byte) error {
9696
r := jlexer.Lexer{Data: data}
9797
easyjson_decode_go_serialization_benchmarks_A(&r, v)
9898
return r.Error()

0 commit comments

Comments
 (0)