Missing "break"?
jrobinso opened this issue · comments
Hey all, great job on this. This is just a question, should there be a break
in this loop (lines 137-143 of src/index.ts)?
It seems to work, but looks odd.
for (let i = 0; i < indexes.length; i++) {
const [key, value] = indexes[i]
const trimmedKey = key.slice(0, searchWord.length)
if (trimmedKey < searchWord) {
start = value
end = value + 65536
}
}
thanks! i think you are right, we probably don't want to put the break in the if-statement
because it can be updated to the "closest index less than the searchWord" on different loop iterations but there could probably be a else { break }
since it would become greater than at that point
I'm porting this to Java, will test it with the else { break } and update if anything else is found. I find your implementation a bit easier to parse than Kent's C code.
Of course just continuing through the loop till the end probably takes 0.1 nanonseconds. I'll close this, it wasn't really an issue just a question.