scanp := dec.scanp
var err error
Input:
- for {
+ // help the compiler see that scanp is never negative, so it can remove
+ // some bounds checks below.
+ for scanp >= 0 {
+
// Look in the buffer for a new value.
- for i, c := range dec.buf[scanp:] {
+ for ; scanp < len(dec.buf); scanp++ {
+ c := dec.buf[scanp]
dec.scan.bytes++
switch dec.scan.step(&dec.scan, c) {
case scanEnd:
- scanp += i
break Input
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
+ scanp++
break Input
}
case scanError:
return 0, dec.scan.err
}
}
- scanp = len(dec.buf)
// Did the last read have an error?
// Delayed until now to allow buffer scan.