Skip to content

Drop EmptyObject and use Object.create(null) again #15001

Closed
@bmeurer

Description

@bmeurer

It seems that new EmptyObject was added as a work-around for Object.create(null) performance. This has a couple of drawbacks for Ember itself, but also comes with a performance penalty in recent Chrome versions (i.e. in all current channels) that include this CL.

From what I can tell, new EmptyObject is often used to create objects that are supposed to be used as dictionaries. But at least in V8 function constructors always create fast mode objects, which means Ember probably wastes (metadata) memory in the browser plus time just to let the engine figure out that it should essentially transition these objects to dictionary mode objects. Object.create(null) always creates a dictionary mode object from the start (since the aforementioned CL landed), and it's compatible with jQuery.isPlainObject and other stuff. The allocation is roughly on par with the performance of new EmptyObject in all current Chrome channels.

So I'd like to trigger a discussion to get rid of EmptyObject.

/cc @krisselden @stefanpenner

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions