-
Notifications
You must be signed in to change notification settings - Fork 184
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
Avoid intermediate JSON object allocations when generating JSON strings #683
Open
osa1
wants to merge
23
commits into
google:master
Choose a base branch
from
osa1:jsontool_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+496
−323
Open
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f8716ae
Split proto3 JSON writer and parser to separate files
osa1 36c3e5e
Split custom JSON writer and parser to separate files
osa1 d23cc3f
Use jsontool to generate proto3 JSON objects and strings
osa1 704bcc1
Update benchmark
osa1 e04e346
Use jsontool in custom JSON format
osa1 739d640
Remove redundant `return`s
osa1 7b900d0
Merge remote-tracking branch 'origin/master' into jsontool_2
osa1 db10c20
Merge remote-tracking branch 'origin/master' into jsontool_2
osa1 9e3aed9
Post-merge fixups
osa1 1418868
Merge remote-tracking branch 'origin/master' into jsontool_2
osa1 9ae3100
Merge remote-tracking branch 'origin/master' into jsontool_2
osa1 09bd61c
Avoid dynamic calls
osa1 f3e10c9
Merge remote-tracking branch 'origin/master' into jsontool_2
osa1 5a6dec5
Add missing return type
osa1 bfd311b
Revert some of the renamings
osa1 de8dcb1
Update changelog
osa1 272e190
Remove explicit type casts
osa1 ac8da6d
Remove writeToJsonSink
osa1 2d566d5
Hide sink API
osa1 572abbc
Minor refactoring
osa1 c741bf9
Rewrite toProto3Json documentation
osa1 20ffa55
Rewording
osa1 1253864
Update changelog
osa1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to expose this?
Not that I expect the interface to change anytime soon, but exposing api from another package is always extra liability (we cannot change without going through jsontool), and as such we should prefer to keep usage internal.
On the other hand we are more or less marrying to the jsontool package here, so it might not matter much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point re: exposing API from another library. No one is requesting this at the moment, and users start using the sink API it will be difficult to migrate to another library later, or maybe drop jsontool entirely.
OTOH if needed we can always add it later without breakage (other than messages with field name
write_to_json_sink
).I'll remove sink methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed
writeToJsonSink
, but we can't removetoProto3JsonSink
because it's called fromAnyMixin
stoProtoJsonHelper
, which now takes a sink argument as well to allow reuse from entry pointstoProto3JsonString
andtoProto3JsonObject
. I think the best we can do is hidingtoProto3JsonSink
in documentation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely a liability to expose a third-party package's API in your API. If they change the API, it affects your API too, which means you might need a tight version constraint.
If the method can be hidden in documentation, it's not clear that users ever need to call it. Could it be made private, and only accessible by calling a special static helper function, like:
and then don't export that function in the public API (
hide
it), just rely on it inAnyMixin
.