You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So instead of parent_links in the tokens themselves, we have a separate side-array used only during parsing to store the "parents stack". Cool idea. There's probably a cache argument to be made, but I don't think it's a concern for JSMN.
If you profile the previous code (with a larger JSON) almost 100% of the time is spent on looking for the parent, but the parent is already known so that's unnecessary work.
A linked list could be used instead of an array on the stack or heap, I didn't think of that in the moment.
If you utilize the token pool for that, then there is no need for a separate API function, so the the final PR would be very minimal.
I guess you just need to link to the last encountered opening { or [ token and they should link to their parent.
Did you try #define JSMN_PARENT_LINKS? How does your solution compare to that? That is the same thing, but done in the token pool itself. Its existence is not really well documented if at all.
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
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.
Greatly accellerates parsing by memoizing toksuper per depth level.
Some tests were also fixed due to conflicts.
I can't spend anymore time on this.