3
3
package jsoniter
4
4
5
5
import (
6
- "reflect"
7
6
"sync"
8
7
)
9
8
@@ -15,39 +14,39 @@ type frozenConfig struct {
15
14
onlyTaggedField bool
16
15
disallowUnknownFields bool
17
16
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
20
19
extensions []Extension
21
20
streamPool chan * Stream
22
21
iteratorPool chan * Iterator
23
22
}
24
23
25
24
func (cfg * frozenConfig ) initCache () {
26
25
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 {}
29
28
}
30
29
31
- func (cfg * frozenConfig ) addDecoderToCache (cacheKey reflect2. Type , decoder ValDecoder ) {
30
+ func (cfg * frozenConfig ) addDecoderToCache (cacheKey uintptr , decoder ValDecoder ) {
32
31
cfg .cacheLock .Lock ()
33
32
cfg .decoderCache [cacheKey ] = decoder
34
33
cfg .cacheLock .Unlock ()
35
34
}
36
35
37
- func (cfg * frozenConfig ) addEncoderToCache (cacheKey reflect2. Type , encoder ValEncoder ) {
36
+ func (cfg * frozenConfig ) addEncoderToCache (cacheKey uintptr , encoder ValEncoder ) {
38
37
cfg .cacheLock .Lock ()
39
38
cfg .encoderCache [cacheKey ] = encoder
40
39
cfg .cacheLock .Unlock ()
41
40
}
42
41
43
- func (cfg * frozenConfig ) getDecoderFromCache (cacheKey reflect2. Type ) ValDecoder {
42
+ func (cfg * frozenConfig ) getDecoderFromCache (cacheKey uintptr ) ValDecoder {
44
43
cfg .cacheLock .RLock ()
45
44
decoder , _ := cfg .decoderCache [cacheKey ].(ValDecoder )
46
45
cfg .cacheLock .RUnlock ()
47
46
return decoder
48
47
}
49
48
50
- func (cfg * frozenConfig ) getEncoderFromCache (cacheKey reflect2. Type ) ValEncoder {
49
+ func (cfg * frozenConfig ) getEncoderFromCache (cacheKey uintptr ) ValEncoder {
51
50
cfg .cacheLock .RLock ()
52
51
encoder , _ := cfg .encoderCache [cacheKey ].(ValEncoder )
53
52
cfg .cacheLock .RUnlock ()
0 commit comments