Skip to content

Cache single line checks based on node id #3129

@nojaf

Description

@nojaf

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions