Skip to content

Commit

Permalink
goto -> for for great justice
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Nov 2, 2023
1 parent 535aca9 commit be56450
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,49 +62,49 @@ var whitespace = [256]bool{
func (s *Scanner) Next() []byte {
s.br.release(s.offset)
w := s.br.window()
loop:
for pos, c := range w {
// strip any leading whitespace.
if whitespace[c] {
continue
}
for {
for pos, c := range w {
// strip any leading whitespace.
if whitespace[c] {
continue
}

// simple case
switch c {
case ObjectStart, ObjectEnd, Colon, Comma, ArrayStart, ArrayEnd:
s.offset = pos + 1
return w[pos:s.offset]
}
// simple case
switch c {
case ObjectStart, ObjectEnd, Colon, Comma, ArrayStart, ArrayEnd:
s.offset = pos + 1
return w[pos:s.offset]
}

s.br.release(pos)
switch c {
case True:
s.offset = validateToken(&s.br, "true")
case False:
s.offset = validateToken(&s.br, "false")
case Null:
s.offset = validateToken(&s.br, "null")
case String:
if s.parseString() < 2 {
return nil
s.br.release(pos)
switch c {
case True:
s.offset = validateToken(&s.br, "true")
case False:
s.offset = validateToken(&s.br, "false")
case Null:
s.offset = validateToken(&s.br, "null")
case String:
if s.parseString() < 2 {
return nil
}
default:
// ensure the number is correct.
s.offset = s.parseNumber(c)
}
default:
// ensure the number is correct.
s.offset = s.parseNumber(c)
return s.br.window()[:s.offset]
}
return s.br.window()[:s.offset]
}

// it's all whitespace, ignore it
s.br.release(len(w))
// it's all whitespace, ignore it
s.br.release(len(w))

// refill buffer
if s.br.extend() == 0 {
// eof
return nil
// refill buffer
if s.br.extend() == 0 {
// eof
return nil
}
w = s.br.window()
}
w = s.br.window()
goto loop
}

func validateToken(br *byteReader, expected string) int {
Expand Down

0 comments on commit be56450

Please sign in to comment.