Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse context at Scanner #487

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions scanner/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/goccy/go-yaml/token"
)

const whitespace = ' '

// Context context at scanning
type Context struct {
idx int
Expand Down Expand Up @@ -49,6 +47,14 @@ func (c *Context) release() {
ctxPool.Put(c)
}

func (c *Context) clear() {
c.resetBuffer()
c.isRawFolded = false
c.isLiteral = false
c.isFolded = false
c.literalOpt = ""
}

func (c *Context) reset(src []rune) {
c.idx = 0
c.size = len(src)
Expand Down Expand Up @@ -144,18 +150,6 @@ func (c *Context) currentChar() rune {
return rune(0)
}

func (c *Context) currentCharWithSkipWhitespace() rune {
idx := c.idx
for c.size > idx {
ch := c.src[idx]
if ch != whitespace {
return ch
}
idx++
}
return rune(0)
}

func (c *Context) nextChar() rune {
if c.size > c.idx+1 {
return c.src[c.idx+1]
Expand Down
Loading
Loading