Files
abra/vendor/github.com/charmbracelet/x/ansi/parser_sync.go
decentral1se 7fb9675b1e
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
chore: golang 1.26 && make deps
2026-04-01 11:25:57 +02:00

30 lines
521 B
Go

package ansi
import (
"sync"
"github.com/charmbracelet/x/ansi/parser"
)
var parserPool = sync.Pool{
New: func() any {
p := NewParser()
p.SetParamsSize(parser.MaxParamsSize)
p.SetDataSize(1024 * 4) // 4KB of data buffer
return p
},
}
// GetParser returns a parser from a sync pool.
func GetParser() *Parser {
return parserPool.Get().(*Parser)
}
// PutParser returns a parser to a sync pool. The parser is reset
// automatically.
func PutParser(p *Parser) {
p.Reset()
p.dataLen = 0
parserPool.Put(p)
}