Skip to content

Entity adapter re-sorts all ids (O(n*log(n)), instead of just inserting the new id into the "right" place (O(log(n))) #4252

Closed
@dutziworks

Description

@dutziworks

Hey 👋

Why is it that when adding (or removing/updating/etc...) items inside an entity-adapter's state, entity-adapter will first push into the array, then run .sort(sortFn) on the entire array?

Wouldn't it make more sense to find the index where the new item should be at (O(log(n)), and splice the ids array?

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