File tree Expand file tree Collapse file tree 1 file changed +24
-13
lines changed Expand file tree Collapse file tree 1 file changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -98,21 +98,32 @@ func (c *cache) getValue() *Value {
98
98
addNext = true
99
99
}
100
100
if addNext {
101
- nextSize := len (c .vs )
102
- if nextSize * 2 < macAllocatedCacheSize {
103
- nextSize *= 2
104
- } else {
105
- nextSize = macAllocatedCacheSize
106
- }
107
- readSrc = & cache {
108
- vs : make ([]Value , 1 , nextSize ),
109
- }
110
- if c .lt != nil {
111
- c .lt .nx = readSrc
101
+ switch {
102
+ case c .lt != nil && c .lt .nx != nil :
112
103
c .lt = c .lt .nx
113
- } else {
114
- c .nx = readSrc
104
+ readSrc = c .lt
105
+ readSrc .vs = readSrc .vs [:1 ]
106
+ case c .lt == nil && c .nx != nil :
115
107
c .lt = c .nx
108
+ readSrc = c .lt
109
+ readSrc .vs = readSrc .vs [:1 ]
110
+ default :
111
+ nextSize := len (c .vs )
112
+ if nextSize * 2 < macAllocatedCacheSize {
113
+ nextSize *= 2
114
+ } else {
115
+ nextSize = macAllocatedCacheSize
116
+ }
117
+ readSrc = & cache {
118
+ vs : make ([]Value , 1 , nextSize ),
119
+ }
120
+ if c .lt != nil {
121
+ c .lt .nx = readSrc
122
+ c .lt = c .lt .nx
123
+ } else {
124
+ c .nx = readSrc
125
+ c .lt = c .nx
126
+ }
116
127
}
117
128
}
118
129
// Do not reset the value, since the caller must properly init it.
You can’t perform that action at this time.
0 commit comments