diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-18 15:05:42 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-18 21:30:12 -0700 |
commit | 0c112bc16d6970db1bee35710f6c8b0622510663 (patch) | |
tree | 1469fc4b2ef6863f77a87114662521b771225c38 | |
parent | a0f2419af917ecc0f91a50b7fb8424615adf9237 (diff) |
decode_scan: Move Reset() to be by PopReadBarrier()
-rw-r--r-- | decode_scan.go | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/decode_scan.go b/decode_scan.go index 7a52975..b0fc7c3 100644 --- a/decode_scan.go +++ b/decode_scan.go @@ -28,28 +28,6 @@ type runeTypeScanner struct { rErr error } -func (sc *runeTypeScanner) Reset() { - sc.parser.Reset() - if sc.repeat || (sc.rType == jsonparse.RuneTypeEOF && sc.rSize > 0) { - sc.repeat = false - // re-figure the rType and rErr - var err error - sc.rType, err = sc.parser.HandleRune(sc.rRune) - if err != nil { - sc.rErr = &DecodeSyntaxError{ - Offset: sc.offset - int64(sc.rSize), - Err: err, - } - } else { - sc.rErr = nil - } - // tell it to use that rType and rErr - _ = sc.UnreadRune() // we set it up to always succeed - } else { - sc.initialized = false - } -} - // The returned error is a *ReadError, a *SyntaxError, or nil. // An EOF condition is represented as one of: // @@ -161,3 +139,25 @@ func (sc *runeTypeScanner) PopReadBarrier() { } } } + +func (sc *runeTypeScanner) Reset() { + sc.parser.Reset() + if sc.repeat || (sc.rType == jsonparse.RuneTypeEOF && sc.rSize > 0) { + sc.repeat = false + // re-figure the rType and rErr + var err error + sc.rType, err = sc.parser.HandleRune(sc.rRune) + if err != nil { + sc.rErr = &DecodeSyntaxError{ + Offset: sc.offset - int64(sc.rSize), + Err: err, + } + } else { + sc.rErr = nil + } + // tell it to use that rType and rErr + _ = sc.UnreadRune() // we set it up to always succeed + } else { + sc.initialized = false + } +} |