Skip to content

Commit df8295a

Browse files
committed
fix 1.8
1 parent 99fc16a commit df8295a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

config_without_sync_map.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package jsoniter
44

55
import (
6-
"reflect"
76
"sync"
87
)
98

@@ -15,39 +14,39 @@ type frozenConfig struct {
1514
onlyTaggedField bool
1615
disallowUnknownFields bool
1716
cacheLock *sync.RWMutex
18-
decoderCache map[reflect2.Type]ValDecoder
19-
encoderCache map[reflect2.Type]ValEncoder
17+
decoderCache map[uintptr]ValDecoder
18+
encoderCache map[uintptr]ValEncoder
2019
extensions []Extension
2120
streamPool chan *Stream
2221
iteratorPool chan *Iterator
2322
}
2423

2524
func (cfg *frozenConfig) initCache() {
2625
cfg.cacheLock = &sync.RWMutex{}
27-
cfg.decoderCache = map[reflect2.Type]ValDecoder{}
28-
cfg.encoderCache = map[reflect2.Type]ValEncoder{}
26+
cfg.decoderCache = map[uintptr]ValDecoder{}
27+
cfg.encoderCache = map[uintptr]ValEncoder{}
2928
}
3029

31-
func (cfg *frozenConfig) addDecoderToCache(cacheKey reflect2.Type, decoder ValDecoder) {
30+
func (cfg *frozenConfig) addDecoderToCache(cacheKey uintptr, decoder ValDecoder) {
3231
cfg.cacheLock.Lock()
3332
cfg.decoderCache[cacheKey] = decoder
3433
cfg.cacheLock.Unlock()
3534
}
3635

37-
func (cfg *frozenConfig) addEncoderToCache(cacheKey reflect2.Type, encoder ValEncoder) {
36+
func (cfg *frozenConfig) addEncoderToCache(cacheKey uintptr, encoder ValEncoder) {
3837
cfg.cacheLock.Lock()
3938
cfg.encoderCache[cacheKey] = encoder
4039
cfg.cacheLock.Unlock()
4140
}
4241

43-
func (cfg *frozenConfig) getDecoderFromCache(cacheKey reflect2.Type) ValDecoder {
42+
func (cfg *frozenConfig) getDecoderFromCache(cacheKey uintptr) ValDecoder {
4443
cfg.cacheLock.RLock()
4544
decoder, _ := cfg.decoderCache[cacheKey].(ValDecoder)
4645
cfg.cacheLock.RUnlock()
4746
return decoder
4847
}
4948

50-
func (cfg *frozenConfig) getEncoderFromCache(cacheKey reflect2.Type) ValEncoder {
49+
func (cfg *frozenConfig) getEncoderFromCache(cacheKey uintptr) ValEncoder {
5150
cfg.cacheLock.RLock()
5251
encoder, _ := cfg.encoderCache[cacheKey].(ValEncoder)
5352
cfg.cacheLock.RUnlock()

0 commit comments

Comments
 (0)