Skip to content
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

unparse.js: don't excessively recompute depth cache for massive speedup #642

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 27, 2023

  1. unparse.js: don't excessively recompute depth cache

    The precomputed values for each rule's min depth should never change
    over the lifetime of an unparse, so compute them up-front instead. By
    precomputing these values, a speedup of multiple orders of magnitude is
    achieved.
    
    Note that there are two levels of caching here: the precomputed values
    never change, but there is also an intermediate depth value cache which
    gets populated with differing values depending on which rule was started
    with. This latter cache is cleared between each precomputing each rule.
    
    This code could be more time-efficient if it lazily computed the min
    depth for each rule as requested, but I suspect any nontrivial depth
    will hit most every rule anyway, and I wanted to keep the code diff
    small and avoid adding more spaghetti.
    seansfkelley committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    12631a8 View commit details
    Browse the repository at this point in the history