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