2020-01-24 15:52:48 +01:00
|
|
|
package opentsdbhttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/valyala/fastjson"
|
|
|
|
)
|
|
|
|
|
2020-09-28 03:11:55 +02:00
|
|
|
// getJSONParser returns JSON parser.
|
2020-01-24 15:52:48 +01:00
|
|
|
//
|
2020-09-28 03:11:55 +02:00
|
|
|
// The parser must be returned to the pool via putJSONParser when no longer needed.
|
|
|
|
func getJSONParser() *fastjson.Parser {
|
2020-01-24 15:52:48 +01:00
|
|
|
return parserPool.Get()
|
|
|
|
}
|
|
|
|
|
2020-09-28 03:11:55 +02:00
|
|
|
// putJSONParser returns p to the pool.
|
2020-01-24 15:52:48 +01:00
|
|
|
//
|
|
|
|
// p cannot be used after returning to the pool.
|
2020-09-28 03:11:55 +02:00
|
|
|
func putJSONParser(p *fastjson.Parser) {
|
2020-01-24 15:52:48 +01:00
|
|
|
parserPool.Put(p)
|
|
|
|
}
|
|
|
|
|
|
|
|
var parserPool fastjson.ParserPool
|