elm/core

Perf optimization: check length/size of lists/sets/dicts/arrays in _Utils_eq

Janiczek opened this issue · 2 comments

Right now there is deep recursive comparison happening even if collection1.length /= collection2.length. It seems to me that we could skip a lot of unneeded work by returning early in those cases.

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

Disclaimer: I'm not that knowledgeable of the kernel code.

Would this be worth it for any type but arrays? The other types are implemented in a recursive/linked list sort of way, so you'd have to traverse the collection to get the length, while the array type seems to be a thin wrapper around regular JavaScript arrays, where getting the length is a constant time operation.