Skip to content

Faster implementation #16

@lovasoa

Description

@lovasoa

In case you are interested, I just published a faster implementation of the same algorithm: lovasoa/fast_array_intersect.

Here are the things you could improve in your version :

  • Fill the initial map using the smallest of the arrays, not the first
  • iterate over arrays using for(var i=0; i<a.length; i++) instead of for(var i in a)
  • implement a premature stopping condition as soon as the intersection is empty
  • (only in ES6) use a Map instead of an object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions