Skip to content

Commit

Permalink
perf: no redundant _addToIndex call or _size invalidation when adding…
Browse files Browse the repository at this point in the history
… existing quad (#403)
  • Loading branch information
jeswr authored Jul 30, 2024
1 parent 426819c commit 5094b2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/N3Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,14 @@ export default class N3Store {
predicate = this._termToNewNumericId(predicate);
object = this._termToNewNumericId(object);

const changed = this._addToIndex(graphItem.subjects, subject, predicate, object);
if (!this._addToIndex(graphItem.subjects, subject, predicate, object))
return false;
this._addToIndex(graphItem.predicates, predicate, object, subject);
this._addToIndex(graphItem.objects, object, subject, predicate);

// The cached quad count is now invalid
this._size = null;
return changed;
return true;
}

// ### `addQuads` adds multiple quads to the store
Expand Down

0 comments on commit 5094b2d

Please sign in to comment.