Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tohhsinpei committed Nov 15, 2022
1 parent 26a95f8 commit 202ac61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions packages/database/src/core/view/filter/LimitedFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,15 @@ export class LimitedFilter implements NodeFilter {
let count = 0;
while (iterator.hasNext() && count < this.limit_) {
const next = iterator.getNext();
const inRange =
this.withinDirectionalStart(next) &&
this.withinDirectionalEnd(next);
if (inRange) {
filtered = filtered.updateImmediateChild(next.name, next.node);
count++;
} else if (!this.withinDirectionalStart(next)) {
if (!this.withinDirectionalStart(next)) {
// if we have not reached the start, skip to the next element
continue;
} else {
} else if (!this.withinDirectionalEnd(next)) {
// if we have reached the end, stop adding elements
break;
} else {
filtered = filtered.updateImmediateChild(next.name, next.node);
count++;
}
}
} else {
Expand Down Expand Up @@ -300,15 +297,15 @@ export class LimitedFilter implements NodeFilter {
this.reverse_ ? this.withinStartPost(node) : this.withinEndPost(node);

private withinStartPost = (node: NamedNode) => {
const compareRes = this.index_.getCompare()(
const compareRes = this.index_.compare(
this.rangedFilter_.getStartPost(),
node
);
return this.startIsInclusive_ ? compareRes <= 0 : compareRes < 0;
};

private withinEndPost = (node: NamedNode) => {
const compareRes = this.index_.getCompare()(
const compareRes = this.index_.compare(
node,
this.rangedFilter_.getEndPost()
);
Expand Down
4 changes: 2 additions & 2 deletions packages/database/test/helpers/syncPointSpec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4216,7 +4216,7 @@
"path": "",
"type": "child_added",
"name": "c",
"prevName": null,
"prevName": "b",
"data": { "index": 9, "value": "c" }
},
{
Expand Down Expand Up @@ -4407,7 +4407,7 @@
"path": "",
"type": "child_added",
"name": "d",
"prevName": null,
"prevName": "c",
"data": { ".value": "d" }
},
{
Expand Down

0 comments on commit 202ac61

Please sign in to comment.