c233270a9b
Previously we were allocating a separate heap object for each token, which creates a lot of small objects for the GC to manage. Since we know that we're always converting from a flat array of native tokens, we can produce a flat array of writer tokens first and _then_ take pointers into that array to achieve our goal of making a slice of pointers. For the use-case of formatting a sequence of tokens by tweaking the "SpacesBefore" value, this means we can get all of our memory allocation done in a single chunk and then just tweak the allocated, contiguous tokens in-place, which should reduce memory pressure for a task which will likely be done frequently by a text editor integration doing "format on save". |
||
---|---|---|
.. | ||
ast.go | ||
doc.go | ||
native_node_sorter.go | ||
parser_test.go | ||
parser.go | ||
tokens.go |