Skip to content

Commit c6c80fa

Browse files
committed
perf: revert encoding.BinaryMarshaler
Signed-off-by: monkey92t <[email protected]>
1 parent 7c11c15 commit c6c80fa

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/proto/writer.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,15 @@ func (w *Writer) WriteArg(v interface{}) error {
101101
return w.bytes(w.numBuf)
102102
case time.Duration:
103103
return w.int(v.Nanoseconds())
104+
case encoding.BinaryMarshaler:
105+
b, err := v.MarshalBinary()
106+
if err != nil {
107+
return err
108+
}
109+
return w.bytes(b)
104110
case net.IP:
105111
return w.bytes(v)
106112
default:
107-
if m, ok := v.(encoding.BinaryMarshaler); ok {
108-
b, err := m.MarshalBinary()
109-
if err != nil {
110-
return err
111-
}
112-
return w.bytes(b)
113-
}
114113
return fmt.Errorf(
115114
"redis: can't marshal %T (implement encoding.BinaryMarshaler)", v)
116115
}

0 commit comments

Comments
 (0)