Skip to content

Rename oxc_allocator's Box and Vec to ArenaBox and ArenaVec #6996

@overlookmotel

Description

@overlookmotel

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::Box becomes ABox
  • oxc_allocator::Vec becomes AVec.

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions