-
-
Notifications
You must be signed in to change notification settings - Fork 933
Description
In oxc_ast we exclusively use Box and Vec from oxc_allocator, so it's easy to know that Box or Vec anywhere in the code means the arena variant.
But this is not the case in transformer, where we are using both oxc_allocator::Vec and std::vec::Vec alongside each other. It's often confusing which Vec refers to, and consequently we've made mistakes, allocating some of transformer's temporary data structures into the arena by accident.
I suggest that we using naming to remove this ambiguity. We could either:
1. Rename the types
oxc_allocator::BoxbecomesABoxoxc_allocator::VecbecomesAVec.
Now anywhere the code says Vec, it's std::vec::Vec, and anywhere it says AVec, it's an arena vec.
We could also use longer names ArenaBox and ArenaVec, but these types are very commonly used, so I think a shorter name is preferable.
2. Naming convention
Don't rename the types.
Instead, adopt a naming convention in transformer (and probably minifier too) when importing arena box/vec:
use oxc_allocator::Box as ABox;
use oxc_allocator::Vec as AVec;This is less fool-proof - it's easy to forget a naming convention - but it's a less intrusive change.
Which?
I'm on the fence. Open to opinions.
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackPriority