Fix error by linter

This commit is contained in:
Masaaki Goshima 2021-02-16 02:24:27 +09:00
parent 64e29e00d6
commit 412dbe93f8
1 changed files with 14 additions and 18 deletions

View File

@ -44,10 +44,6 @@ func (s *stream) totalOffset() int64 {
return s.offset + s.cursor return s.offset + s.cursor
} }
func (s *stream) prevChar() byte {
return s.buf[s.cursor-1]
}
func (s *stream) char() byte { func (s *stream) char() byte {
return s.buf[s.cursor] return s.buf[s.cursor]
} }
@ -103,7 +99,7 @@ LOOP:
func (s *stream) skipObject() error { func (s *stream) skipObject() error {
braceCount := 1 braceCount := 1
buf, cursor, p := s.stat() _, cursor, p := s.stat()
for { for {
switch char(p, cursor) { switch char(p, cursor) {
case '{': case '{':
@ -119,7 +115,7 @@ func (s *stream) skipObject() error {
cursor++ cursor++
switch char(p, cursor) { switch char(p, cursor) {
case '"': case '"':
if buf[cursor-1] == '\\' { if char(p, cursor-1) == '\\' {
continue continue
} }
goto SWITCH_OUT goto SWITCH_OUT
@ -127,7 +123,7 @@ func (s *stream) skipObject() error {
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
s.cursor-- // for retry current character s.cursor-- // for retry current character
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("string of object", cursor) return errUnexpectedEndOfJSON("string of object", cursor)
@ -136,7 +132,7 @@ func (s *stream) skipObject() error {
case nul: case nul:
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("object of object", cursor) return errUnexpectedEndOfJSON("object of object", cursor)
@ -148,7 +144,7 @@ func (s *stream) skipObject() error {
func (s *stream) skipArray() error { func (s *stream) skipArray() error {
bracketCount := 1 bracketCount := 1
buf, cursor, p := s.stat() _, cursor, p := s.stat()
for { for {
switch char(p, cursor) { switch char(p, cursor) {
case '[': case '[':
@ -164,7 +160,7 @@ func (s *stream) skipArray() error {
cursor++ cursor++
switch char(p, cursor) { switch char(p, cursor) {
case '"': case '"':
if buf[cursor-1] == '\\' { if char(p, cursor-1) == '\\' {
continue continue
} }
goto SWITCH_OUT goto SWITCH_OUT
@ -172,7 +168,7 @@ func (s *stream) skipArray() error {
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
s.cursor-- // for retry current character s.cursor-- // for retry current character
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("string of object", cursor) return errUnexpectedEndOfJSON("string of object", cursor)
@ -181,7 +177,7 @@ func (s *stream) skipArray() error {
case nul: case nul:
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("array of object", cursor) return errUnexpectedEndOfJSON("array of object", cursor)
@ -192,7 +188,7 @@ func (s *stream) skipArray() error {
} }
func (s *stream) skipValue() error { func (s *stream) skipValue() error {
buf, cursor, p := s.stat() _, cursor, p := s.stat()
for { for {
switch char(p, cursor) { switch char(p, cursor) {
case ' ', '\n', '\t', '\r': case ' ', '\n', '\t', '\r':
@ -201,7 +197,7 @@ func (s *stream) skipValue() error {
case nul: case nul:
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("value of object", s.totalOffset()) return errUnexpectedEndOfJSON("value of object", s.totalOffset())
@ -214,9 +210,9 @@ func (s *stream) skipValue() error {
case '"': case '"':
for { for {
cursor++ cursor++
switch buf[cursor] { switch char(p, cursor) {
case '"': case '"':
if buf[cursor-1] == '\\' { if char(p, cursor-1) == '\\' {
continue continue
} }
s.cursor = cursor + 1 s.cursor = cursor + 1
@ -225,7 +221,7 @@ func (s *stream) skipValue() error {
s.cursor = cursor s.cursor = cursor
if s.read() { if s.read() {
s.cursor-- // for retry current character s.cursor-- // for retry current character
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
return errUnexpectedEndOfJSON("value of string", s.totalOffset()) return errUnexpectedEndOfJSON("value of string", s.totalOffset())
@ -240,7 +236,7 @@ func (s *stream) skipValue() error {
} else if c == nul { } else if c == nul {
if s.read() { if s.read() {
s.cursor-- // for retry current character s.cursor-- // for retry current character
buf, cursor, p = s.stat() _, cursor, p = s.stat()
continue continue
} }
} }