Skip to content

Commit e55c5e7

Browse files
Cleanup
1 parent 5e5f31f commit e55c5e7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/firestore/src/local/indexeddb_index_manager.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -847,29 +847,27 @@ export class IndexedDbIndexManager implements IndexManager {
847847
return indexRanges;
848848
}
849849

850-
// The values need to be sorted so that we can return a sorted set of
851-
// non-overlapping ranges.
852-
notInValues.sort((l, r) => compareByteArrays(l, r));
853-
854-
const notInRanges: IDBKeyRange[] = [];
850+
const result: IDBKeyRange[] = [];
855851
for (const indexRange of indexRanges) {
856852
// Remove notIn values that are not applicable to this index range
853+
const lowerBound = new Uint8Array(indexRange.lower[3]);
854+
const upperBound = new Uint8Array(indexRange.upper[3]);
857855
const filteredRanges = notInValues.filter(
858856
v =>
859-
compareByteArrays(v, new Uint8Array(indexRange.lower[3])) >= 0 &&
860-
compareByteArrays(v, new Uint8Array(indexRange.upper[3])) <= 0
857+
compareByteArrays(v, lowerBound) >= 0 &&
858+
compareByteArrays(v, upperBound) <= 0
861859
);
862860

863861
if (filteredRanges.length === 0) {
864-
notInRanges.push(indexRange);
862+
result.push(indexRange);
865863
} else {
866864
// Use the existing bounds and interleave the notIn values. This means
867865
// that we would split an existing range into multiple ranges that exclude
868866
// the values from any notIn filter.
869-
notInRanges.push(...this.interleaveRanges(indexRange, filteredRanges));
867+
result.push(...this.interleaveRanges(indexRange, filteredRanges));
870868
}
871869
}
872-
return notInRanges;
870+
return result;
873871
}
874872

875873
/**
@@ -881,6 +879,10 @@ export class IndexedDbIndexManager implements IndexManager {
881879
indexRange: IDBKeyRange,
882880
barriers: Uint8Array[]
883881
): IDBKeyRange[] {
882+
// The values need to be sorted so that we can return a sorted set of
883+
// non-overlapping ranges.
884+
barriers.sort((l, r) => compareByteArrays(l, r));
885+
884886
const ranges: IDBKeyRange[] = [];
885887

886888
// The first index range starts with the lower bound and ends before the

0 commit comments

Comments
 (0)