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

Cache single line checks based on node id #3129

Open
nojaf opened this issue Oct 9, 2024 · 0 comments
Open

Cache single line checks based on node id #3129

nojaf opened this issue Oct 9, 2024 · 0 comments

Comments

@nojaf
Copy link
Contributor

nojaf commented Oct 9, 2024

This is more of a shower thought, but I wanted to write it down somewhere.

Ever since the Dallas rewrite, we can create our own Oak nodes.

What we don't currently do, but totally can, is insert a unique ID for each node.

In CodePrinter, we have a lot of code that tries to format everything on a single line and takes a different code path if it doesn't fit.

We could probably cache the results of a single-line node printing attempt (using that unique ID). This would allow us to easily reuse the result along with the current column.

For example, if we tried to format node#37 at column 12 as a single line, and it didn’t work, we should only attempt to format node#37 again as a single line if the current column is less than 12.

//cc @josh-degraw @dawedawe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant