Skip to content

Optimize Map.prototype.getOrInsertComputed #1157

@bnoordhuis

Description

@bnoordhuis

It currently searches the map twice (both before and after calling the user-provided JS function) because the user's function can change the map.

That's uncommon though, and can be avoided by adding a change counter to JSMapState. If the counter didn't change, the user's function didn't change the map, and we don't have to search again.

It means the set and delete operations have to do more work though, so I'm not fully convinced it's a net win. I'm opening this as a reminder to myself so I don't forget.

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