|
4 | 4 | "encoding" |
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
| 7 | + "maps" |
7 | 8 | "math/big" |
8 | 9 | "reflect" |
9 | 10 | "sort" |
@@ -73,12 +74,9 @@ func cacheLoad() map[unsafe.Pointer]codec { |
73 | 74 |
|
74 | 75 | func cacheStore(typ reflect.Type, cod codec, oldCodecs map[unsafe.Pointer]codec) { |
75 | 76 | newCodecs := make(map[unsafe.Pointer]codec, len(oldCodecs)+1) |
| 77 | + maps.Copy(newCodecs, oldCodecs) |
76 | 78 | newCodecs[typeid(typ)] = cod |
77 | 79 |
|
78 | | - for t, c := range oldCodecs { |
79 | | - newCodecs[t] = c |
80 | | - } |
81 | | - |
82 | 80 | cache.Store(&newCodecs) |
83 | 81 | } |
84 | 82 |
|
@@ -205,7 +203,7 @@ func constructCodec(t reflect.Type, seen map[reflect.Type]*structType, canAddr b |
205 | 203 | c = constructUnsupportedTypeCodec(t) |
206 | 204 | } |
207 | 205 |
|
208 | | - p := reflect.PtrTo(t) |
| 206 | + p := reflect.PointerTo(t) |
209 | 207 |
|
210 | 208 | if canAddr { |
211 | 209 | switch { |
@@ -291,7 +289,7 @@ func constructSliceCodec(t reflect.Type, seen map[reflect.Type]*structType) code |
291 | 289 | // Go 1.7+ behavior: slices of byte types (and aliases) may override the |
292 | 290 | // default encoding and decoding behaviors by implementing marshaler and |
293 | 291 | // unmarshaler interfaces. |
294 | | - p := reflect.PtrTo(e) |
| 292 | + p := reflect.PointerTo(e) |
295 | 293 | c := codec{} |
296 | 294 |
|
297 | 295 | switch { |
@@ -391,7 +389,7 @@ func constructMapCodec(t reflect.Type, seen map[reflect.Type]*structType) codec |
391 | 389 | kc := codec{} |
392 | 390 | vc := constructCodec(v, seen, false) |
393 | 391 |
|
394 | | - if k.Implements(textMarshalerType) || reflect.PtrTo(k).Implements(textUnmarshalerType) { |
| 392 | + if k.Implements(textMarshalerType) || reflect.PointerTo(k).Implements(textUnmarshalerType) { |
395 | 393 | kc.encode = constructTextMarshalerEncodeFunc(k, false) |
396 | 394 | kc.decode = constructTextUnmarshalerDecodeFunc(k, true) |
397 | 395 |
|
@@ -972,7 +970,6 @@ type structType struct { |
972 | 970 | ficaseIndex map[string]*structField |
973 | 971 | keyset []byte |
974 | 972 | typ reflect.Type |
975 | | - inlined bool |
976 | 973 | } |
977 | 974 |
|
978 | 975 | type structField struct { |
@@ -1095,10 +1092,10 @@ var ( |
1095 | 1092 | timeType = reflect.TypeOf(time.Time{}) |
1096 | 1093 | rawMessageType = reflect.TypeOf(RawMessage(nil)) |
1097 | 1094 |
|
1098 | | - numberPtrType = reflect.PtrTo(numberType) |
1099 | | - durationPtrType = reflect.PtrTo(durationType) |
1100 | | - timePtrType = reflect.PtrTo(timeType) |
1101 | | - rawMessagePtrType = reflect.PtrTo(rawMessageType) |
| 1095 | + numberPtrType = reflect.PointerTo(numberType) |
| 1096 | + durationPtrType = reflect.PointerTo(durationType) |
| 1097 | + timePtrType = reflect.PointerTo(timeType) |
| 1098 | + rawMessagePtrType = reflect.PointerTo(rawMessageType) |
1102 | 1099 |
|
1103 | 1100 | sliceInterfaceType = reflect.TypeOf(([]any)(nil)) |
1104 | 1101 | sliceStringType = reflect.TypeOf(([]any)(nil)) |
|
0 commit comments