1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-06 22:36:25 +02:00

optimize code

This commit is contained in:
Xargin 2017-09-06 13:14:54 +08:00
parent bc3221879d
commit b134d86290

View File

@ -202,8 +202,7 @@ func (decoder *fuzzyIntegerDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It
case jsoniter.StringValue: case jsoniter.StringValue:
str = iter.ReadString() str = iter.ReadString()
case jsoniter.BoolValue: case jsoniter.BoolValue:
b := iter.ReadBool() if iter.ReadBool() {
if b == true {
str = "1" str = "1"
} else { } else {
str = "0" str = "0"
@ -239,8 +238,7 @@ func (decoder *fuzzyFloat32Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It
} }
case jsoniter.BoolValue: case jsoniter.BoolValue:
// support bool to float32 // support bool to float32
b := iter.ReadBool() if iter.ReadBool() {
if b == true {
*((*float32)(ptr)) = 1 *((*float32)(ptr)) = 1
} else { } else {
*((*float32)(ptr)) = 0 *((*float32)(ptr)) = 0
@ -269,8 +267,7 @@ func (decoder *fuzzyFloat64Decoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It
} }
case jsoniter.BoolValue: case jsoniter.BoolValue:
// support bool to float64 // support bool to float64
b := iter.ReadBool() if iter.ReadBool() {
if b == true {
*((*float64)(ptr)) = 1 *((*float64)(ptr)) = 1
} else { } else {
*((*float64)(ptr)) = 0 *((*float64)(ptr)) = 0