Skip to content

Remove ObjectProperty's init field #7252

@overlookmotel

Description

@overlookmotel

ObjectProperty currently looks like this:

pub struct ObjectProperty<'a> {
    pub span: Span,
    pub kind: PropertyKind,
    pub key: PropertyKey<'a>,
    pub value: Expression<'a>,
    pub init: Option<Expression<'a>>, // for `CoverInitializedName`
    pub method: bool,
    pub shorthand: bool,
    pub computed: bool,
}

As I understand it, the init field is only used within parser as a temporary value, but final AST will always have this field as None.

It'd be ideal to remove this field for 2 reasons:

  1. It adds 16 bytes to ObjectProperty, and ObjectProperty is extremely common in ASTs, so it's not an insignificant cost.
  2. It's something of a footgun. Code should never set init field to anything other than None, but it currently can.

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