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 Manager.setAllModsEnabled #1191

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

anttimaki
Copy link
Collaborator

  • Skip processing the mods that already are in the desired state
  • Update VueX store only once at the end, not after each mod, since this will trigger a costly rerendering (which will be addressed separately

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

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

Should probably wrap the logic to a try/catch to avoid state drift on a thrown error? Even though a lot of the code uses the paradigm where errors are returned instead of thrown, nothing actually guarantees this to be the case throughout all the code paths (this is also the main reason why I don't like this paradigm in JS; you need to be prepared to handle exceptions anyway and I'm not aware of any linters that could guarantee all potential exceptions are getting handled.)

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 534 to 536
const name = `Error ${enabled ? "enabling" : "disabling"} mods`;
const message = (e as Error).message;
this.showError(new R2Error(name, message));
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a R2Error.fromThrownValue class method (or something like that) available which you can use for this kind of stuff btw

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to use fromThrownValue.

- Skip processing the mods that already are in the desired state
- Update VueX store only once at the end, not after each mod, since
  this will trigger a costly rerendering (which will be addressed
  separately
- Wrap the logic in try-catch to avoid state drift on unexpected
  errors
@anttimaki anttimaki merged commit dbb1c8c into develop Feb 2, 2024
4 checks passed
@anttimaki anttimaki deleted the enable-all-mods-performance branch February 2, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants