Skip to content

Commit 38afbc3

Browse files
authored
chore: use readquads in filtered to improve perf. (#285)
1 parent 65e9e33 commit 38afbc3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/N3Store.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,13 @@ class DatasetCoreAndReadableStream extends Readable {
787787
get filtered() {
788788
if (!this._filtered) {
789789
const { n3Store, graph, object, predicate, subject } = this;
790-
const quads = n3Store.getQuads(subject, predicate, object, graph);
791-
this._filtered = new N3Store(quads, { factory: n3Store._factory });
790+
const newStore = this._filtered = new N3Store({ factory: n3Store._factory });
791+
for (const quad of n3Store.readQuads(subject, predicate, object, graph))
792+
newStore.addQuad(quad);
792793
}
793794
return this._filtered;
794795
}
796+
795797
get size() {
796798
return this.filtered.size;
797799
}

0 commit comments

Comments
 (0)