aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/stream.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/stream.go')
-rw-r--r--src/encoding/json/stream.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/encoding/json/stream.go b/src/encoding/json/stream.go
index 63aa030955..7d5137fbc7 100644
--- a/src/encoding/json/stream.go
+++ b/src/encoding/json/stream.go
@@ -96,19 +96,19 @@ Input:
// Look in the buffer for a new value.
for i, c := range dec.buf[scanp:] {
dec.scan.bytes++
- v := dec.scan.step(&dec.scan, c)
- if v == scanEnd {
+ switch dec.scan.step(&dec.scan, c) {
+ case scanEnd:
scanp += i
break Input
- }
- // scanEnd is delayed one byte.
- // We might block trying to get that byte from src,
- // so instead invent a space byte.
- if (v == scanEndObject || v == scanEndArray) && dec.scan.step(&dec.scan, ' ') == scanEnd {
- scanp += i + 1
- break Input
- }
- if v == scanError {
+ case scanEndObject, scanEndArray:
+ // scanEnd is delayed one byte.
+ // We might block trying to get that byte from src,
+ // so instead invent a space byte.
+ if stateEndValue(&dec.scan, ' ') == scanEnd {
+ scanp += i + 1
+ break Input
+ }
+ case scanError:
dec.err = dec.scan.err
return 0, dec.scan.err
}