forked from valyala/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper string escaping and arena deepcopy #2
Merged
paralin
merged 10 commits into
aperturerobotics:master
from
klondikedragon:proper-escaping-and-deepcopy
Sep 8, 2024
Merged
Proper string escaping and arena deepcopy #2
paralin
merged 10 commits into
aperturerobotics:master
from
klondikedragon:proper-escaping-and-deepcopy
Sep 8, 2024
Conversation
This file contains 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
klondikedragon
commented
Sep 1, 2024
- Merged the fix to string escape during serialization from escapeString compatibility with encoding/json valyala/fastjson#87 (thanks @barkyq!)
- Added unit tests to ensure string escape exactly matches standard library behavior (no bugs found)
- Added Arena.DeepCopyValue, which can be used to change the lifecycle of a Value (e.g., to extend the lifetime of a Value returned by Scanner)
- Added Arena.NewNumberStringBytes function - creates a new number from the arena storing the string bytes data inside the arena - can be useful by those already managing values and arena scope carefully to store other related string data
- Added Arena.AllocateStringFromStringBytes function to allocate and copy arbitrary string bytes data into the arena
- Clarified instructions for ArenaPool.Put to make sure callers get the benefit that they expect
- Made concurrent tests for Arena more rigorous and refactored into a generic test driver
- Small fixups to existing unit tests
and `encoding/json` from standard library
it is in range 0x23-0x5B see page 8 of: https://www.rfc-editor.org/rfc/rfc8259.html this should not be a problem though, if the unescape is applied to properly escaped json data
This reverts commit 7a86309.
Tests for string escape conformance with standard lib
Useful when needing to get the original representation of the number. This is needed when wanting to make an exact copy of a Value.
Arena.DeepCopyValue is useful to change the lifecycle of a Value (e.g., to extend the lifetime of a Value returned by Scanner) Also add: * Arena.NewNumberStringBytes - creates a new number from the arena storing the string bytes data inside the arena * Arena.AllocateStringFromStringBytes - utility function to allocate and copy arbitrary string bytes data into the arena Also clarified instructions for ArenaPool.Put to make sure callers get the benefit that they expect.
This was referenced Sep 1, 2024
Thanks, this looks great! I'll review and merge tomorrow. |
Looks good, thanks. |
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.