Skip to content

Commit 4ef4fc0

Browse files
committed
chore: don't mint new ids unecessarily
1 parent 19ed891 commit 4ef4fc0

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

src/N3Store.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class N3Store {
3737
this._termFromId(entities[terms[1]]),
3838
this._termFromId(entities[terms[2]]),
3939
this._termFromId(entities[terms[3]])
40+
// terms[4] && this._termFromId(entities[terms[4]])
4041
);
4142
return q;
4243
}
@@ -45,6 +46,7 @@ export default class N3Store {
4546

4647
_termToId(term) {
4748
if (term && term.termType === 'Quad') {
49+
// const g = this._termToNewNumericId(term.graph)
4850
const res = `.${
4951
this._termToNewNumericId(term.subject)
5052
}.${
@@ -330,8 +332,8 @@ export default class N3Store {
330332
// and verify the quad exists.
331333
const graphs = this._graphs;
332334
let graphItem, subjects, predicates;
333-
if (!(subject = this._termToNewNumericId(subject)) || !(predicate = this._termToNewNumericId(predicate)) ||
334-
!(object = this._termToNewNumericId(object)) || !(graphItem = graphs[graph]) ||
335+
if (!(subject = subject && this._termToNumericId(subject)) || !(predicate = predicate && this._termToNumericId(predicate)) ||
336+
!(object = object && this._termToNumericId(object)) || !(graphItem = graphs[graph]) ||
335337
!(subjects = graphItem.subjects[subject]) ||
336338
!(predicates = subjects[predicate]) ||
337339
!(object in predicates))
@@ -396,9 +398,9 @@ export default class N3Store {
396398
let content, subjectId, predicateId, objectId;
397399

398400
// Translate IRIs to internal index keys.
399-
if (subject && !(subjectId = this._termToNewNumericId(subject)) ||
400-
predicate && !(predicateId = this._termToNewNumericId(predicate)) ||
401-
object && !(objectId = this._termToNewNumericId(object)))
401+
if (subject && !(subjectId = this._termToNumericId(subject)) ||
402+
predicate && !(predicateId = this._termToNumericId(predicate)) ||
403+
object && !(objectId = this._termToNumericId(object)))
402404
return;
403405

404406
for (const graphId in graphs) {
@@ -451,9 +453,9 @@ export default class N3Store {
451453
let count = 0, content, subjectId, predicateId, objectId;
452454

453455
// Translate IRIs to internal index keys.
454-
if (subject && !(subjectId = this._termToNewNumericId(subject)) ||
455-
predicate && !(predicateId = this._termToNewNumericId(predicate)) ||
456-
object && !(objectId = this._termToNewNumericId(object)))
456+
if (subject && !(subjectId = this._termToNumericId(subject)) ||
457+
predicate && !(predicateId = this._termToNumericId(predicate)) ||
458+
object && !(objectId = this._termToNumericId(object)))
457459
return 0;
458460

459461
for (const graphId in graphs) {
@@ -531,8 +533,8 @@ export default class N3Store {
531533
callback = this._uniqueEntities(callback);
532534

533535
// Translate IRIs to internal index keys.
534-
if (predicate && !(predicateId = this._termToNewNumericId(predicate)) ||
535-
object && !(objectId = this._termToNewNumericId(object)))
536+
if (predicate && !(predicateId = this._termToNumericId(predicate)) ||
537+
object && !(objectId = this._termToNumericId(object)))
536538
return;
537539

538540
for (graph in graphs) {
@@ -576,8 +578,8 @@ export default class N3Store {
576578
callback = this._uniqueEntities(callback);
577579

578580
// Translate IRIs to internal index keys.
579-
if (subject && !(subjectId = this._termToNewNumericId(subject)) ||
580-
object && !(objectId = this._termToNewNumericId(object)))
581+
if (subject && !(subjectId = this._termToNumericId(subject)) ||
582+
object && !(objectId = this._termToNumericId(object)))
581583
return;
582584

583585
for (graph in graphs) {
@@ -621,8 +623,8 @@ export default class N3Store {
621623
callback = this._uniqueEntities(callback);
622624

623625
// Translate IRIs to internal index keys.
624-
if (subject && !(subjectId = this._termToNewNumericId(subject)) ||
625-
predicate && !(predicateId = this._termToNewNumericId(predicate)))
626+
if (subject && !(subjectId = this._termToNumericId(subject)) ||
627+
predicate && !(predicateId = this._termToNumericId(predicate)))
626628
return;
627629

628630
for (graph in graphs) {

0 commit comments

Comments
 (0)