Remove unreachable error checking

This commit is contained in:
Masaaki Goshima 2020-04-22 15:31:44 +09:00
parent 31f2422545
commit aa0aff6388
1 changed files with 0 additions and 21 deletions

View File

@ -179,9 +179,6 @@ func (e *Encoder) encode(v reflect.Value, ptr unsafe.Pointer) error {
if err != nil { if err != nil {
return err return err
} }
if op == nil {
return nil
}
if name != "" { if name != "" {
cachedEncodeOp[name] = op cachedEncodeOp[name] = op
} }
@ -242,9 +239,6 @@ func (e *Encoder) compilePtr(typ reflect.Type) (EncodeOp, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if op == nil {
return nil, nil
}
return func(enc *Encoder, p uintptr) { return func(enc *Encoder, p uintptr) {
op(enc, e.ptrToPtr(p)) op(enc, e.ptrToPtr(p))
}, nil }, nil
@ -312,9 +306,6 @@ func (e *Encoder) compileSlice(typ reflect.Type) (EncodeOp, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if op == nil {
return nil, nil
}
return func(enc *Encoder, base uintptr) { return func(enc *Encoder, base uintptr) {
if base == 0 { if base == 0 {
enc.encodeString("null") enc.encodeString("null")
@ -340,9 +331,6 @@ func (e *Encoder) compileArray(typ reflect.Type) (EncodeOp, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if op == nil {
return nil, nil
}
return func(enc *Encoder, base uintptr) { return func(enc *Encoder, base uintptr) {
if base == 0 { if base == 0 {
enc.encodeString("null") enc.encodeString("null")
@ -395,9 +383,6 @@ func (e *Encoder) compileStruct(typ reflect.Type) (EncodeOp, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if op == nil {
continue
}
key := fmt.Sprintf(`"%s":`, keyName) key := fmt.Sprintf(`"%s":`, keyName)
opQueue = append(opQueue, func(enc *Encoder, base uintptr) { opQueue = append(opQueue, func(enc *Encoder, base uintptr) {
enc.encodeString(key) enc.encodeString(key)
@ -448,16 +433,10 @@ func (e *Encoder) compileMap(typ reflect.Type) (EncodeOp, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if keyOp == nil {
return nil, nil
}
valueOp, err := e.compile(typ.Elem()) valueOp, err := e.compile(typ.Elem())
if err != nil { if err != nil {
return nil, err return nil, err
} }
if valueOp == nil {
return nil, nil
}
return func(enc *Encoder, base uintptr) { return func(enc *Encoder, base uintptr) {
if base == 0 { if base == 0 {
enc.encodeString("null") enc.encodeString("null")