File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -35,18 +35,17 @@ func New(buffer []byte) ReflectionDecoder {
3535// Decode decodes the data value at offset and stores it in the value
3636// pointed at by v.
3737func (d * ReflectionDecoder ) Decode (offset uint , v any ) error {
38+ // Check if the type implements Unmarshaler interface without reflection
39+ if unmarshaler , ok := v .(Unmarshaler ); ok {
40+ decoder := NewDecoder (d .DataDecoder , offset )
41+ return unmarshaler .UnmarshalMaxMindDB (decoder )
42+ }
43+
3844 rv := reflect .ValueOf (v )
3945 if rv .Kind () != reflect .Ptr || rv .IsNil () {
4046 return errors .New ("result param must be a pointer" )
4147 }
4248
43- // Check if the type implements Unmarshaler interface using cached type check
44- if rv .Type ().Implements (unmarshalerType ) {
45- unmarshaler := v .(Unmarshaler ) // Safe, we know it implements
46- decoder := NewDecoder (d .DataDecoder , offset )
47- return unmarshaler .UnmarshalMaxMindDB (decoder )
48- }
49-
5049 _ , err := d .decode (offset , rv , 0 )
5150 if err == nil {
5251 return nil
You can’t perform that action at this time.
0 commit comments