bablr-lang / agast-vm

A VM providing DOM-like guarantees about agAST trees
MIT License
1 stars 0 forks source link

Symbol-typed CST nodes #1

Open conartist6 opened 1 month ago

conartist6 commented 1 month ago

Change { type: 'Name' } to { type: Symbol('Name') } across our APIs. This is expected to bring a roughly 2x speedup to equality checks against node.type due to the extremely straightforward nature of symbol comparison. String comparison does have relatively fast cases for interned strings, but likely the fact that comparison between two interned strings is only one of many possible types of string comparison means that string comparison is will probably continue to be slower than symbol comparison well into the future.

The real implementation cannot be { type: Symbol('Name') } though, as the Symbol('Name') expression must be created only once so that all references to the Name production can do so using the same symbol. The VM will need to manage these symbols, making them available through context.