Skip to content

Commit

Permalink
fix: upgrade to rc.7
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Jan 15, 2024
1 parent 535889f commit 83c3e3a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions source/optims/constantFolding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Engine, {
parseExpression,
serializeEvaluation,
} from 'publicodes'
import type { RuleNode, ASTNode, Unit } from 'publicodes'
import type { RuleNode, ASTNode } from 'publicodes'
import {
getAllRefsInNode,
RuleName,
Expand Down Expand Up @@ -360,7 +360,7 @@ function updateRefCounting(
if (ctx.refs.parents.get(ruleNameToUpdate)?.length === 0) {
deleteRule(ctx, ruleNameToUpdate)
}
})
}
}

function tryToFoldRule(
Expand Down Expand Up @@ -388,7 +388,7 @@ function tryToFoldRule(
return
}

const { nodeValue, missingVariables, unit } = ctx.engine.evaluateNode(rule)
const evaluatedNode = ctx.engine.evaluateNode(rule)

if ('valeur' in rule.rawNode) {
rule.rawNode.formule = rule.rawNode.valeur
Expand Down Expand Up @@ -457,17 +457,14 @@ export function constantFolding(
console.timeEnd('copy')

console.time('initFoldingCtx')
let ctx: FoldingCtx = {
engine,
parsedRules,
toKeep,
refs: getRefs(parsedRules),
params: params?.isFoldedAttr ? params : { isFoldedAttr: 'optimized' },
}
let ctx = initFoldingCtx(engine, parsedRules, toKeep, params)
console.timeEnd('initFoldingCtx')

for (const [ruleName, ruleNode] of Object.entries(ctx.parsedRules)) {
if (isFoldable(ruleNode) && !isAlreadyFolded(ctx.params, ruleNode)) {
if (
isFoldable(ruleNode, ctx.impactedByContexteRules) &&
!isAlreadyFolded(ctx.params, ruleNode)
) {
tryToFoldRule(ctx, ruleName, ruleNode)
}
}
Expand Down

0 comments on commit 83c3e3a

Please sign in to comment.