Use JSON.parse instead of literal JS for callback formatting#1370
Merged
lucasfernog merged 19 commits intotauri-apps:devfrom Apr 7, 2021
Merged
Use JSON.parse instead of literal JS for callback formatting#1370lucasfernog merged 19 commits intotauri-apps:devfrom
lucasfernog merged 19 commits intotauri-apps:devfrom
Conversation
lucasfernog
reviewed
Mar 29, 2021
lucasfernog
reviewed
Mar 29, 2021
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Contributor
Author
|
Tested the following conditions:
|
…uble String::replace())
Contributor
Author
|
Lines 9 to 55 in f57b533 |
nklayman
suggested changes
Apr 6, 2021
Member
nklayman
left a comment
There was a problem hiding this comment.
Looks good overall, just a few suggestions. Also, the formatting appears to be off, make sure to reformat the rpc.rs file when you're done.
nklayman
reviewed
Apr 6, 2021
lucasfernog
approved these changes
Apr 6, 2021
Member
lucasfernog
left a comment
There was a problem hiding this comment.
I love this, such a clever PR!
Member
|
Delete line 56 to fix the check btw. |
Member
|
Looks like you need to rerun formatting on it :/ |
12 tasks
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.
https://github.com/GoogleChromeLabs/json-parse-benchmark
What kind of change does this PR introduce? (check at least one)
Optimisation
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
Other information:
Believe it or not,
JSON.parseis actually faster than directly evaluating literal JavaScript for JSON objects.It does actually make sense - when evaluating actual JavaScript the interpreter is looking for variables to interpolate, and is using a parsing pipeline made for interpreting actual code. Whereas with
JSON.parse, it's just looking at raw JSON, which is of course much faster than interpreting actual JavaScript.This should introduce up to x2 speed improvements for formatting callback JS.
Unfortunately I don't know how to set up the dev environment for Tauri right now, it's very complex and I failed the last time I tried. Just want to get this PR up here so it will at least eventually be implemented. If I manage to get a dev environment set up or a maintainer can contribute (edits are on) then the following stuff needs doing for this PR to be complete:
{or[(the speed improvement only applies for JSON objects/arrays, not literals such as strings, booleans, numbers, etc.)