From b9b8a0c9bfa783f4f45b02caad8ec9745f56d9d9 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Sat, 5 Dec 2020 23:21:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20Correction=20de=20l'algo=20de=20?= =?UTF-8?q?d=C3=A9sactivation=20d'espace=20de=20nom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La vérification de l'applicabilité du parent faisait un aller/retour inutile entre la règle enfant et la règle parent, à l'origine d'une régression de performance. --- publicodes/source/rule.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/publicodes/source/rule.ts b/publicodes/source/rule.ts index c7d6a2fff..e7f0cab52 100644 --- a/publicodes/source/rule.ts +++ b/publicodes/source/rule.ts @@ -114,18 +114,13 @@ registerEvaluationFunction('rule', function evaluate(node) { return this.cache[node.dottedName] } const explanation = { ...node.explanation } - this.cache._meta.contextRule.push(node.dottedName) - this.cache._meta.parentEvaluationStack ??= [] + const verifyParentApplicability = !this.cache._meta.contextRule.includes(node.dottedName) + this.cache._meta.contextRule.push(node.dottedName) let parent: EvaluatedNode | null = null - if ( - explanation.parent && - !this.cache._meta.parentEvaluationStack.includes(node.dottedName) - ) { - this.cache._meta.parentEvaluationStack.push(node.dottedName) + if (explanation.parent && verifyParentApplicability) { parent = this.evaluateNode(explanation.parent) as EvaluatedNode explanation.parent = parent - this.cache._meta.parentEvaluationStack.pop() } let valeur: EvaluatedNode | null = null if (!parent || parent.nodeValue !== false) {