diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-01-11 02:25:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 02:25:41 -0800 |
commit | 26f2b7debde313af4a5ae39727c66a3f8fd59be4 (patch) | |
tree | 1ab2968feabc60768ac04c7f832ddfb93f97e3ad /vendor/github.com/json-iterator/go/pool.go | |
parent | 36d96c19f947aeac2675afe64a3b482e54f9e4c4 (diff) | |
parent | 3966d3bf4e6be2975c330af64ce6ba86b4eeabe0 (diff) | |
download | podman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.tar.gz podman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.tar.bz2 podman-26f2b7debde313af4a5ae39727c66a3f8fd59be4.zip |
Merge pull request #2105 from mheon/jsoniter
Use jsoniter instead of easyjson
Diffstat (limited to 'vendor/github.com/json-iterator/go/pool.go')
-rw-r--r-- | vendor/github.com/json-iterator/go/pool.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/json-iterator/go/pool.go b/vendor/github.com/json-iterator/go/pool.go new file mode 100644 index 000000000..e2389b56c --- /dev/null +++ b/vendor/github.com/json-iterator/go/pool.go @@ -0,0 +1,42 @@ +package jsoniter + +import ( + "io" +) + +// IteratorPool a thread safe pool of iterators with same configuration +type IteratorPool interface { + BorrowIterator(data []byte) *Iterator + ReturnIterator(iter *Iterator) +} + +// StreamPool a thread safe pool of streams with same configuration +type StreamPool interface { + BorrowStream(writer io.Writer) *Stream + ReturnStream(stream *Stream) +} + +func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream { + stream := cfg.streamPool.Get().(*Stream) + stream.Reset(writer) + return stream +} + +func (cfg *frozenConfig) ReturnStream(stream *Stream) { + stream.out = nil + stream.Error = nil + stream.Attachment = nil + cfg.streamPool.Put(stream) +} + +func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator { + iter := cfg.iteratorPool.Get().(*Iterator) + iter.ResetBytes(data) + return iter +} + +func (cfg *frozenConfig) ReturnIterator(iter *Iterator) { + iter.Error = nil + iter.Attachment = nil + cfg.iteratorPool.Put(iter) +} |