You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
use sync.Pool
This commit is contained in:
13
config.go
13
config.go
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"unsafe"
|
||||
"github.com/v2pro/plz/reflect2"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Config customize how the API should behave.
|
||||
@ -66,8 +67,16 @@ func (cfg Config) Froze() API {
|
||||
objectFieldMustBeSimpleString: cfg.ObjectFieldMustBeSimpleString,
|
||||
onlyTaggedField: cfg.OnlyTaggedField,
|
||||
disallowUnknownFields: cfg.DisallowUnknownFields,
|
||||
streamPool: make(chan *Stream, 16),
|
||||
iteratorPool: make(chan *Iterator, 16),
|
||||
}
|
||||
api.streamPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return NewStream(api, nil, 512)
|
||||
},
|
||||
}
|
||||
api.iteratorPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return NewIterator(api)
|
||||
},
|
||||
}
|
||||
api.initCache()
|
||||
encoderExtension := EncoderExtension{}
|
||||
|
Reference in New Issue
Block a user