mirror of https://github.com/goccy/go-json.git
Fix stream decoder
This commit is contained in:
parent
ab068b0858
commit
f3167760ff
|
@ -82,7 +82,14 @@ func (s *stream) readBuf() []byte {
|
|||
copy(s.buf, remainBuf)
|
||||
}
|
||||
remainLen := s.length - s.cursor
|
||||
return s.buf[s.cursor+remainLen:]
|
||||
remainNotNulCharNum := int64(0)
|
||||
for i := int64(0); i < remainLen; i++ {
|
||||
if s.buf[s.cursor+i] == nul {
|
||||
break
|
||||
}
|
||||
remainNotNulCharNum++
|
||||
}
|
||||
return s.buf[s.cursor+remainNotNulCharNum:]
|
||||
}
|
||||
|
||||
func (s *stream) read() bool {
|
||||
|
|
|
@ -213,6 +213,7 @@ func stringBytes(s *stream) ([]byte, error) {
|
|||
s.buf = append(append(append([]byte{}, s.buf[:cursor]...), runeErrBytes...), s.buf[cursor+1:]...)
|
||||
_, _, p = s.stat()
|
||||
cursor += runeErrBytesLen
|
||||
s.length += runeErrBytesLen
|
||||
continue
|
||||
case nul:
|
||||
s.cursor = cursor
|
||||
|
@ -238,6 +239,7 @@ func stringBytes(s *stream) ([]byte, error) {
|
|||
_, _, p = s.stat()
|
||||
}
|
||||
cursor += int64(len(b))
|
||||
s.length += int64(len(b))
|
||||
continue
|
||||
}
|
||||
cursor++
|
||||
|
|
Loading…
Reference in New Issue