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 {
35
35
// Decode decodes the data value at offset and stores it in the value
36
36
// pointed at by v.
37
37
func (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
+
38
44
rv := reflect .ValueOf (v )
39
45
if rv .Kind () != reflect .Ptr || rv .IsNil () {
40
46
return errors .New ("result param must be a pointer" )
41
47
}
42
48
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
-
50
49
_ , err := d .decode (offset , rv , 0 )
51
50
if err == nil {
52
51
return nil
You can’t perform that action at this time.
0 commit comments