Skip to content

Commit 56e7441

Browse files
Next round
1 parent ba1507f commit 56e7441

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/firestore/src/local/indexeddb_index_manager.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,24 @@ export class IndexedDbIndexManager implements IndexManager {
873873
const bounds: IndexEntry[] = [];
874874
bounds.push(lower);
875875
for (const notInValue of notInValues) {
876-
const sortsAfter = indexEntryComparator(notInValue, lower);
877-
const sortsBefore = indexEntryComparator(notInValue, upper);
876+
const cpmToLower = indexEntryComparator(notInValue, lower);
877+
const cmpToUpper = indexEntryComparator(notInValue, upper);
878878

879-
if (sortsAfter > 0 && sortsBefore < 0) {
879+
if (cpmToLower === 0) {
880+
// `notInValue` is the lower bound. We therefore need to raise the bound
881+
// to the next value.
882+
bounds[0] = lower.successor();
883+
} else if (cpmToLower > 0 && cmpToUpper < 0) {
884+
// `notInValue` is in the middle of the range
880885
bounds.push(notInValue);
881886
bounds.push(notInValue.successor());
882-
} else if (sortsAfter === 0) {
883-
// The lowest value in the range is excluded
884-
bounds[0] = lower.successor();
885-
} else if (sortsBefore === 0) {
886-
// The largest value in the range is excluded
887+
} else if (cmpToUpper === 0) {
888+
// `notInValue` is the upper value. We therefore need to exclude the
889+
// upper bound.
887890
upperInclusive = false;
891+
} else {
892+
// `notInValue` (and all following values) are out of the range
893+
break;
888894
}
889895
}
890896
bounds.push(upper);

0 commit comments

Comments
 (0)