fix: eliminate repeated printer function execution from our naively-implemented 'call' helper #771
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.
What changed with this PR:
Our
callhelper is implemented by calling AstPath'smapmethod and indexing into the returned array. This PR removes the ability to index to anything other than0, to prevent it from being used to execute individual calls to individual path indices, which was causing all indices to be re-processed each timecallwas executed, which in some cases (such as long if-else statement chains) was causing printer functions to be executed an exponential number of times (according to the number of if-else statements in the chain). Anything that was previously using the indexing feature ofcallis now updated to either use themaphelper once, and index into the results, or useAstPath.calldirectly, which is a bit more verbose, but it's a rare use-case in our printer to begin with.Example
Input
Output
The same, but it no longer takes an exponential amount of time to print.
Relative issues or prs:
Closes #757