ajitid / fzf-for-js

Do fuzzy matching using FZF algorithm in JavaScript
https://fzf.netlify.app
BSD 3-Clause "New" or "Revised" License
888 stars 21 forks source link

fix: merge large result lists safely #69

Closed reinhrst closed 3 years ago

reinhrst commented 3 years ago

result.push(...scoreMap[score]) expands to a function call with scoreMap[score].length parameters, which breaks when scoreMap[score].length > max allowed parameters for a function (which supposedly is something around 65k).

This replaces the result array on each iteration. I was afraid that this might be a bit slower, but actually code is about 1% faster in my (very limited) tests. Memory usage is about 0.3% higher.

netlify[bot] commented 3 years ago

✔️ Deploy Preview for fzf ready!

🔨 Explore the source changes: 5d785aa138f0bcbb62a9e008f12c09733c779f07

🔍 Inspect the deploy log: https://app.netlify.com/sites/fzf/deploys/611ad514a1b35a0007f4abce

😎 Browse the preview: https://deploy-preview-69--fzf.netlify.app/

ajitid commented 3 years ago

scoreMap[score].length > max allowed parameters for a function

It never occurred to me. Thanks for the contribution!