-3 loops per iteration by only incrementing loop count when math is actually being handled

This commit is contained in:
Ean Milligan 2025-08-06 14:40:46 -04:00
parent 6bf671f82d
commit 4a5e33c9a0
1 changed files with 4 additions and 5 deletions

View File

@ -98,11 +98,10 @@ export const mathSolver = (conf: MathConf[], wrapDetails = false): SolvedStep =>
loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Evaluating ${JSON.stringify(curOps)}`);
// Iterate thru all operators/operands in the conf
for (let i = 0; i < conf.length; i++) {
loopCountCheck('mathSolver.ts - evaluating roll');
loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Evaluating ${JSON.stringify(curOps)} | Checking ${JSON.stringify(conf[i])}`);
// Check if the current index is in the active tier of operators
if (curOps.includes(conf[i].toString())) {
loopCountCheck('mathSolver.ts - evaluating roll');
// Grab the operands from before and after the operator
const operand1 = conf[i - 1];
const operand2 = conf[i + 1];