Ver Fonte

fix 1.8

Tao Wen há 7 anos atrás
pai
commit
df8295a48a
1 ficheiros alterados com 8 adições e 9 exclusões
  1. 8 9
      config_without_sync_map.go

+ 8 - 9
config_without_sync_map.go

@@ -3,7 +3,6 @@
 package jsoniter
 
 import (
-	"reflect"
 	"sync"
 )
 
@@ -15,8 +14,8 @@ type frozenConfig struct {
 	onlyTaggedField               bool
 	disallowUnknownFields         bool
 	cacheLock                     *sync.RWMutex
-	decoderCache                  map[reflect2.Type]ValDecoder
-	encoderCache                  map[reflect2.Type]ValEncoder
+	decoderCache                  map[uintptr]ValDecoder
+	encoderCache                  map[uintptr]ValEncoder
 	extensions                    []Extension
 	streamPool                    chan *Stream
 	iteratorPool                  chan *Iterator
@@ -24,30 +23,30 @@ type frozenConfig struct {
 
 func (cfg *frozenConfig) initCache() {
 	cfg.cacheLock = &sync.RWMutex{}
-	cfg.decoderCache = map[reflect2.Type]ValDecoder{}
-	cfg.encoderCache = map[reflect2.Type]ValEncoder{}
+	cfg.decoderCache = map[uintptr]ValDecoder{}
+	cfg.encoderCache = map[uintptr]ValEncoder{}
 }
 
-func (cfg *frozenConfig) addDecoderToCache(cacheKey reflect2.Type, decoder ValDecoder) {
+func (cfg *frozenConfig) addDecoderToCache(cacheKey uintptr, decoder ValDecoder) {
 	cfg.cacheLock.Lock()
 	cfg.decoderCache[cacheKey] = decoder
 	cfg.cacheLock.Unlock()
 }
 
-func (cfg *frozenConfig) addEncoderToCache(cacheKey reflect2.Type, encoder ValEncoder) {
+func (cfg *frozenConfig) addEncoderToCache(cacheKey uintptr, encoder ValEncoder) {
 	cfg.cacheLock.Lock()
 	cfg.encoderCache[cacheKey] = encoder
 	cfg.cacheLock.Unlock()
 }
 
-func (cfg *frozenConfig) getDecoderFromCache(cacheKey reflect2.Type) ValDecoder {
+func (cfg *frozenConfig) getDecoderFromCache(cacheKey uintptr) ValDecoder {
 	cfg.cacheLock.RLock()
 	decoder, _ := cfg.decoderCache[cacheKey].(ValDecoder)
 	cfg.cacheLock.RUnlock()
 	return decoder
 }
 
-func (cfg *frozenConfig) getEncoderFromCache(cacheKey reflect2.Type) ValEncoder {
+func (cfg *frozenConfig) getEncoderFromCache(cacheKey uintptr) ValEncoder {
 	cfg.cacheLock.RLock()
 	encoder, _ := cfg.encoderCache[cacheKey].(ValEncoder)
 	cfg.cacheLock.RUnlock()