-
-
Notifications
You must be signed in to change notification settings - Fork 932
Description
I think TriviasMap (which contains Comments) could be converted to a Vec.
If I remember right, it was a Vec originally, but was converted to a BTreeMap to work around a problem with comments getting inserted twice when lexer looks ahead and is then rewound.
This problem could still be avoided if it was a Vec. Comments are inserted in source text order, so duplicates could be avoided by checking before pushing whether the last entry's span start is equal or greater than the comment being inserted. If it is, don't push it again.
Seeking by span start could be still performed efficiently with a binary search.
As it's a flat Vec, there would be no significant gain to storing it in arena. std::vec::Vec is fine.
As mentioned in oxc#3580, Trivias could also be stored in Allocator so you can get a &'a Trivias with same lifetime as Program<'a>.
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackPriority