Fixed performance regression in dependency graph speed
This commit is contained in:
@@ -9,8 +9,15 @@ export default function linkCalculationDependencies(dependencyGraph, prop, { pro
|
|||||||
};
|
};
|
||||||
// Add this calculation to the dependency graph
|
// Add this calculation to the dependency graph
|
||||||
const calcNodeId = `${prop._id}.${calcObj._key}`;
|
const calcNodeId = `${prop._id}.${calcObj._key}`;
|
||||||
dependencyGraph.addNode(calcNodeId, calcObj);
|
|
||||||
|
|
||||||
|
// Skip empty calculations that aren't targeted by anything
|
||||||
|
if (
|
||||||
|
!calcObj.calculation
|
||||||
|
&& !calcObj.effects
|
||||||
|
&& !calcObj.proficiencies
|
||||||
|
) return;
|
||||||
|
|
||||||
|
dependencyGraph.addNode(calcNodeId, calcObj);
|
||||||
// Traverse the parsed calculation looking for variable names
|
// Traverse the parsed calculation looking for variable names
|
||||||
traverse(calcObj.parseNode, node => {
|
traverse(calcObj.parseNode, node => {
|
||||||
// Skip nodes that aren't symbols or accessors
|
// Skip nodes that aren't symbols or accessors
|
||||||
|
|||||||
@@ -98,8 +98,10 @@ function linkAdjustment(dependencyGraph, prop) {
|
|||||||
|
|
||||||
function linkAttribute(dependencyGraph, prop) {
|
function linkAttribute(dependencyGraph, prop) {
|
||||||
linkVariableName(dependencyGraph, prop);
|
linkVariableName(dependencyGraph, prop);
|
||||||
// Depends on spellSlotLevel
|
// Spell slots depend on spellSlotLevel
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'spellSlotLevel' });
|
if (prop.type === 'spellSlot') {
|
||||||
|
dependOnCalc({ dependencyGraph, prop, key: 'spellSlotLevel' });
|
||||||
|
}
|
||||||
|
|
||||||
// Depends on base value
|
// Depends on base value
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'baseValue' });
|
dependOnCalc({ dependencyGraph, prop, key: 'baseValue' });
|
||||||
@@ -257,8 +259,8 @@ function linkDamageMultiplier(dependencyGraph, prop) {
|
|||||||
function linkPointBuy(dependencyGraph, prop) {
|
function linkPointBuy(dependencyGraph, prop) {
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'min' });
|
dependOnCalc({ dependencyGraph, prop, key: 'min' });
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'max' });
|
dependOnCalc({ dependencyGraph, prop, key: 'max' });
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'cost' });
|
|
||||||
dependOnCalc({ dependencyGraph, prop, key: 'total' });
|
dependOnCalc({ dependencyGraph, prop, key: 'total' });
|
||||||
|
|
||||||
prop.values?.forEach((row, index) => {
|
prop.values?.forEach((row, index) => {
|
||||||
// Get a unique id for the row because it might be shared among duplicated point buy tables
|
// Get a unique id for the row because it might be shared among duplicated point buy tables
|
||||||
// prop._id is forced unique by the database, so it can be used instead
|
// prop._id is forced unique by the database, so it can be used instead
|
||||||
@@ -273,9 +275,7 @@ function linkPointBuy(dependencyGraph, prop) {
|
|||||||
}
|
}
|
||||||
dependencyGraph.addNode(pointBuyRow._id, pointBuyRow);
|
dependencyGraph.addNode(pointBuyRow._id, pointBuyRow);
|
||||||
linkVariableName(dependencyGraph, pointBuyRow);
|
linkVariableName(dependencyGraph, pointBuyRow);
|
||||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'min' });
|
dependencyGraph.addLink(pointBuyRow._id, prop._id, 'pointBuyRow');
|
||||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'max' });
|
|
||||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'cost' });
|
|
||||||
});
|
});
|
||||||
if (prop.inactive) return;
|
if (prop.inactive) return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user