forked from mirror/go-json
Remove goto statement
This commit is contained in:
parent
3574217593
commit
ceed634708
|
@ -23,13 +23,12 @@ func (d *stringDecoder) decode(buf []byte, cursor int, p uintptr) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *stringDecoder) decodeByte(buf []byte, cursor int) ([]byte, int, error) {
|
func (d *stringDecoder) decodeByte(buf []byte, cursor int) ([]byte, int, error) {
|
||||||
LOOP:
|
for {
|
||||||
switch buf[cursor] {
|
switch buf[cursor] {
|
||||||
case '\000':
|
case '\000':
|
||||||
return nil, 0, errors.New("unexpected error key delimiter")
|
return nil, 0, errors.New("unexpected error key delimiter")
|
||||||
case ' ', '\n', '\t', '\r':
|
case ' ', '\n', '\t', '\r':
|
||||||
cursor++
|
cursor++
|
||||||
goto LOOP
|
|
||||||
case '"':
|
case '"':
|
||||||
cursor++
|
cursor++
|
||||||
start := cursor
|
start := cursor
|
||||||
|
@ -64,5 +63,6 @@ LOOP:
|
||||||
cursor += 5
|
cursor += 5
|
||||||
return []byte{'n', 'u', 'l', 'l'}, cursor, nil
|
return []byte{'n', 'u', 'l', 'l'}, cursor, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil, 0, errors.New("unexpected error key delimiter")
|
return nil, 0, errors.New("unexpected error key delimiter")
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,10 @@ func (d *structDecoder) skipValue(buf []byte, cursor int) (int, error) {
|
||||||
braceCount := 0
|
braceCount := 0
|
||||||
bracketCount := 0
|
bracketCount := 0
|
||||||
buflen := len(buf)
|
buflen := len(buf)
|
||||||
for ; cursor < buflen; cursor++ {
|
for {
|
||||||
switch buf[cursor] {
|
switch buf[cursor] {
|
||||||
|
case '\000':
|
||||||
|
return cursor, errors.New("unexpected error value")
|
||||||
case '{':
|
case '{':
|
||||||
braceCount++
|
braceCount++
|
||||||
case '[':
|
case '[':
|
||||||
|
@ -59,6 +61,7 @@ func (d *structDecoder) skipValue(buf []byte, cursor int) (int, error) {
|
||||||
}
|
}
|
||||||
QUOTE_END:
|
QUOTE_END:
|
||||||
}
|
}
|
||||||
|
cursor++
|
||||||
}
|
}
|
||||||
return cursor, errors.New("unexpected error value")
|
return cursor, errors.New("unexpected error value")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue