forked from toolshed/abra
chore: make deps, go mod vendor
This commit is contained in:
29
vendor/github.com/charmbracelet/x/ansi/parser_sync.go
generated
vendored
Normal file
29
vendor/github.com/charmbracelet/x/ansi/parser_sync.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package ansi
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/charmbracelet/x/ansi/parser"
|
||||
)
|
||||
|
||||
var parserPool = sync.Pool{
|
||||
New: func() any {
|
||||
p := NewParser(nil)
|
||||
p.SetParamsSize(parser.MaxParamsSize)
|
||||
p.SetDataSize(1024 * 1024 * 4) // 4MB 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)
|
||||
}
|
Reference in New Issue
Block a user