fix: unexpected behavior when buffer ends with backslash#383
Merged
goccy merged 7 commits intogoccy:masterfrom Aug 3, 2022
Merged
fix: unexpected behavior when buffer ends with backslash#383goccy merged 7 commits intogoccy:masterfrom
goccy merged 7 commits intogoccy:masterfrom
Conversation
HurSungYun
reviewed
Jul 18, 2022
Co-authored-by: Sungyun Hur <ethan0311@gmail.com>
HurSungYun
reviewed
Jul 18, 2022
internal/decoder/stream.go
Outdated
| @@ -344,6 +345,7 @@ func (s *Stream) skipArray(depth int64) error { | |||
| s.cursor = cursor | |||
| if s.read() { | |||
| _, cursor, p = s.statForRetry() | |||
Contributor
There was a problem hiding this comment.
what about adding a new parameter rewindCursor in statForRetry? (or make a new function)
func (s *Stream) statForRetry(rewindCursor bool) ([]byte, int64, unsafe.Pointer) {
if rewindCursor {
s.cursor-- // for retry ( because caller may progress cursor position in each loop )
}
return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data
}
It may confuse when additional cursor increments happens outside of statForRetry function.
Contributor
Author
|
@goccy Could you please review this PR? |
goccy
reviewed
Aug 1, 2022
internal/decoder/stream.go
Outdated
| s.cursor = cursor | ||
| if s.read() { | ||
| _, cursor, p = s.statForRetry() | ||
| cursor++ |
Owner
There was a problem hiding this comment.
Please use s.stat() instead of s.statForRetry() and remove cursor++
Contributor
Author
There was a problem hiding this comment.
This looks clearer! I reflected your review in the following commit.
Owner
|
Thank you for the contribution !! LGTM ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #384
by increasing cursor by 1 to escape character properly.