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) {
|
||||
LOOP:
|
||||
for {
|
||||
switch buf[cursor] {
|
||||
case '\000':
|
||||
return nil, 0, errors.New("unexpected error key delimiter")
|
||||
case ' ', '\n', '\t', '\r':
|
||||
cursor++
|
||||
goto LOOP
|
||||
case '"':
|
||||
cursor++
|
||||
start := cursor
|
||||
|
@ -64,5 +63,6 @@ LOOP:
|
|||
cursor += 5
|
||||
return []byte{'n', 'u', 'l', 'l'}, cursor, nil
|
||||
}
|
||||
}
|
||||
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
|
||||
bracketCount := 0
|
||||
buflen := len(buf)
|
||||
for ; cursor < buflen; cursor++ {
|
||||
for {
|
||||
switch buf[cursor] {
|
||||
case '\000':
|
||||
return cursor, errors.New("unexpected error value")
|
||||
case '{':
|
||||
braceCount++
|
||||
case '[':
|
||||
|
@ -59,6 +61,7 @@ func (d *structDecoder) skipValue(buf []byte, cursor int) (int, error) {
|
|||
}
|
||||
QUOTE_END:
|
||||
}
|
||||
cursor++
|
||||
}
|
||||
return cursor, errors.New("unexpected error value")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue