Skip to content

pick: Implement Fisher-Yates left to right instead of right to left #30

@webmaster128

Description

@webmaster128

When implementing the algorithm the other way around, the result is in the left positions of the input vector. This allows us to return the result by truncating such which saves a new allocation for the result.

This is how lodash implement's it as well: https://github.com/lodash/lodash/blob/4.17.21/lodash.js#L6767-L6790

However, it's unclear if it is worth the change and should be benchmarked in Wasm. Especially since pick would typically have not too many result items.

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