Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use shared index on dataset methods #405

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/N3Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ export default class N3Store {
* This method is aligned with Array.prototype.filter() in ECMAScript-262.
*/
filter(iteratee) {
const store = new N3Store();
const store = new N3Store({ entityIndex: this._entityIndex });
for (const quad of this)
if (iteratee(quad, this))
store.add(quad);
Expand All @@ -884,7 +884,7 @@ export default class N3Store {
* Returns a new dataset containing all quads returned by applying `iteratee` to each quad in the current dataset.
*/
map(iteratee) {
const store = new N3Store();
const store = new N3Store({ entityIndex: this._entityIndex });
for (const quad of this)
store.add(iteratee(quad, this));
return store;
Expand Down Expand Up @@ -946,7 +946,7 @@ export default class N3Store {
* Returns a new `Dataset` that is a concatenation of this dataset and the quads given as an argument.
*/
union(quads) {
const store = new N3Store();
const store = new N3Store({ entityIndex: this._entityIndex });
store.addAll(this);
store.addAll(quads);
return store;
Expand Down