Re:Fuzzysearch: Tiny, fast fuzzy searching for JavaScript
by nightcracker on Monday July 20, 2015 @10:16AM
(#9916157)
I don't know why the author coded it this way, it can be done much simpler:
[ Parent
| on HN ]
Re:Fuzzysearch: Tiny, fast fuzzy searching for JavaScript
by joshstrange on Monday July 20, 2015 @12:26PM
(#9917110)
He says the algorithm was suggested by "Mr. Aleph, a crazy russian compiler engineer working at V8.". It's possible it was suggested to be written this way because V8 (and possibly other interpreters) can optimise it to be faster.
Re:Fuzzysearch: Tiny, fast fuzzy searching for JavaScript
by mraleph on Monday July 20, 2015 @10:40AM
(#9916337)
It's written with continue precisely to avoid additional `if (j === hlen)` check after the loop and having a single increment of `j` in the loop :)
To be honest reasoning about the loop with continue is actually easier than about one without.