2020-01-24 14:52:48 +00:00
|
|
|
package opentsdbhttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/valyala/fastjson"
|
|
|
|
)
|
|
|
|
|
2023-02-13 18:14:17 +00:00
|
|
|
// GetJSONParser returns JSON parser.
|
2020-01-24 14:52:48 +00:00
|
|
|
//
|
2023-02-13 18:14:17 +00:00
|
|
|
// The parser must be returned to the pool via PutJSONParser when no longer needed.
|
|
|
|
func GetJSONParser() *fastjson.Parser {
|
2020-01-24 14:52:48 +00:00
|
|
|
return parserPool.Get()
|
|
|
|
}
|
|
|
|
|
2023-02-13 18:14:17 +00:00
|
|
|
// PutJSONParser returns p to the pool.
|
2020-01-24 14:52:48 +00:00
|
|
|
//
|
|
|
|
// p cannot be used after returning to the pool.
|
2023-02-13 18:14:17 +00:00
|
|
|
func PutJSONParser(p *fastjson.Parser) {
|
2020-01-24 14:52:48 +00:00
|
|
|
parserPool.Put(p)
|
|
|
|
}
|
|
|
|
|
|
|
|
var parserPool fastjson.ParserPool
|