Skip to content

Unnecessary triggering of performCalculations() #736

@hzla

Description

@hzla

Loading a new set is currently recalculating the same result 10-16 times. This is due to using change() on dom objects to trigger an update of the UI. For example:

$(".status").change();
moveObj.change();
abilityObj.change();

This happens numerous times throughout the function and each time change() is called on an object with the class calc-trigger, it causes the calc to redo the calculations even though none of the input has changed. I can see that the intended result of using change() seems to just be to update the UI so that the appropriate options like ability toggles or number of move hits show up and not to actually alter the damage calculation results.

Another 6 extra duplicate calculations come from here for pokemon with alternate forms.

baseStat.keyup();

Perhaps the UI updating code can be separated out and called directly when needed instead of just using change() is updated to prevent these duplicate calls. While it doesn't really affect the user experience for the base calc, it does improve performance for anyone who forks the calc and adds additional functionality to performCalculations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions