Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of batch feat updates #18014

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CarlosFdez
Copy link
Collaborator

@CarlosFdez CarlosFdez commented Jan 17, 2025

For an otherwise bare bones swashbuckler with 6 finisher options, it speeds up adjusting the toggle's selected suboption from 212ms to 27ms. Larger actors will lead to larger gulfs (which I've witnessed sometimes approach seconds).

You can test on a swashie with the sheet closed by selecting the token and running
foundry.utils.benchmark(() => _token.actor.toggleRollOption("all", "finisher", null, true, _token.actor.synthetics.toggles.all.finisher.suboptions.find((s) => !s.selected).value), 50)

const actor = documents.find((d): d is ItemPF2e => d instanceof ItemPF2e)?.actor;
if (actor) {
operation.previousSystemData = fu.mergeObject(operation.previousSystemData ?? {}, {
maxHitPoints: actor.hitPoints?.max,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepared value?

Copy link
Collaborator Author

@CarlosFdez CarlosFdez Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean to use actor.system.attributes.hp.max instead? Actor is a document, so it should already be the prepared value.

src/module/item/base/document.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants