From 2fdd4652d882ecd620b44b85cc2668ac951600c7 Mon Sep 17 00:00:00 2001 From: Jesse Wright Date: Thu, 12 May 2022 18:42:53 +1000 Subject: [PATCH] perf remove unecessary calcs (#279) --- src/N3Store.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/N3Store.js b/src/N3Store.js index ed8f8407..4bc90f3c 100644 --- a/src/N3Store.js +++ b/src/N3Store.js @@ -91,26 +91,22 @@ export default class N3Store { const varCount = !key0 + !key1 + !key2, entityKeys = varCount > 1 ? Object.keys(this._ids) : this._entities; const graph = termFromId(graphId, this._factory); + const parts = { subject: null, predicate: null, object: null }; // If a key is specified, use only that part of index 0. if (key0) (tmp = index0, index0 = {})[key0] = tmp[key0]; for (const value0 in index0) { - const entity0 = entityKeys[value0]; - if (index1 = index0[value0]) { + parts[name0] = termFromId(entityKeys[value0], this._factory); // If a key is specified, use only that part of index 1. if (key1) (tmp = index1, index1 = {})[key1] = tmp[key1]; for (const value1 in index1) { - const entity1 = entityKeys[value1]; - if (index2 = index1[value1]) { + parts[name1] = termFromId(entityKeys[value1], this._factory); // If a key is specified, use only that part of index 2, if it exists. const values = key2 ? (key2 in index2 ? [key2] : []) : Object.keys(index2); // Create quads for all items found in index 2. for (let l = 0; l < values.length; l++) { - const parts = { subject: null, predicate: null, object: null }; - parts[name0] = termFromId(entity0, this._factory); - parts[name1] = termFromId(entity1, this._factory); parts[name2] = termFromId(entityKeys[values[l]], this._factory); yield this._factory.quad(parts.subject, parts.predicate, parts.object, graph); }