Skip to content

Commit b47b487

Browse files
GerHobbeltjasonLaster
authored andcommitted
binary-search precision improvement: (#393)
+ `===` precise numeric enum check for bias + typo fix in comment
1 parent da4f5a7 commit b47b487

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/binary-search.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
4545

4646
// The exact needle element was not found in this haystack. Determine if
4747
// we are in termination case (3) or (2) and return the appropriate thing.
48-
if (aBias == exports.LEAST_UPPER_BOUND) {
48+
if (aBias === exports.LEAST_UPPER_BOUND) {
4949
return aHigh < aHaystack.length ? aHigh : -1;
5050
}
5151
return mid;
@@ -93,7 +93,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
9393
return -1;
9494
}
9595

96-
// We have found either the exact element, or the next-closest element than
96+
// We have found either the exact element, or the next-closest element to
9797
// the one we are searching for. However, there may be more than one such
9898
// element. Make sure we always return the smallest of these.
9999
while (index - 1 >= 0) {

0 commit comments

Comments
 (0)