Skip to content

Commit 202ac61

Browse files
committed
Address PR feedback
1 parent 26a95f8 commit 202ac61

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

packages/database/src/core/view/filter/LimitedFilter.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,15 @@ export class LimitedFilter implements NodeFilter {
125125
let count = 0;
126126
while (iterator.hasNext() && count < this.limit_) {
127127
const next = iterator.getNext();
128-
const inRange =
129-
this.withinDirectionalStart(next) &&
130-
this.withinDirectionalEnd(next);
131-
if (inRange) {
132-
filtered = filtered.updateImmediateChild(next.name, next.node);
133-
count++;
134-
} else if (!this.withinDirectionalStart(next)) {
128+
if (!this.withinDirectionalStart(next)) {
135129
// if we have not reached the start, skip to the next element
136130
continue;
137-
} else {
131+
} else if (!this.withinDirectionalEnd(next)) {
138132
// if we have reached the end, stop adding elements
139133
break;
134+
} else {
135+
filtered = filtered.updateImmediateChild(next.name, next.node);
136+
count++;
140137
}
141138
}
142139
} else {
@@ -300,15 +297,15 @@ export class LimitedFilter implements NodeFilter {
300297
this.reverse_ ? this.withinStartPost(node) : this.withinEndPost(node);
301298

302299
private withinStartPost = (node: NamedNode) => {
303-
const compareRes = this.index_.getCompare()(
300+
const compareRes = this.index_.compare(
304301
this.rangedFilter_.getStartPost(),
305302
node
306303
);
307304
return this.startIsInclusive_ ? compareRes <= 0 : compareRes < 0;
308305
};
309306

310307
private withinEndPost = (node: NamedNode) => {
311-
const compareRes = this.index_.getCompare()(
308+
const compareRes = this.index_.compare(
312309
node,
313310
this.rangedFilter_.getEndPost()
314311
);

packages/database/test/helpers/syncPointSpec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,7 +4216,7 @@
42164216
"path": "",
42174217
"type": "child_added",
42184218
"name": "c",
4219-
"prevName": null,
4219+
"prevName": "b",
42204220
"data": { "index": 9, "value": "c" }
42214221
},
42224222
{
@@ -4407,7 +4407,7 @@
44074407
"path": "",
44084408
"type": "child_added",
44094409
"name": "d",
4410-
"prevName": null,
4410+
"prevName": "c",
44114411
"data": { ".value": "d" }
44124412
},
44134413
{

0 commit comments

Comments
 (0)