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

perf: Simplify getSettings() #2734

Open
claremacrae opened this issue Mar 25, 2024 · 0 comments
Open

perf: Simplify getSettings() #2734

claremacrae opened this issue Mar 25, 2024 · 0 comments
Labels
priority: high A high priority/important request scope: performance issues Issues with speed or responsiveness type: internal Only regards development or contributing

Comments

@claremacrae
Copy link
Collaborator

Description

getSettings() is called often in the plugin.

It currently does a lot of work for every call:

export const getSettings = (): Settings => {
    // Check to see if there are any new options that need to be added to the user's settings.
    addNewOptionsToUserSettings(Feature.settingsFlags, settings.features);
    addNewOptionsToUserSettings(defaultSettings.loggingOptions.minLevels, settings.loggingOptions.minLevels);
    addNewOptionsToUserSettings(defaultSettings.debugSettings, settings.debugSettings);

    // In case saves pre-dated StatusConfiguration.type
    // TODO Special case for symbol 'X' or 'x' (just in case)
    settings.statusSettings.customStatuses.forEach((s, index, array) => {
        const newType = Status.getTypeFromStatusTypeString(s.type);
        array[index] = new StatusConfiguration(
            s.symbol ?? ' ',
            s.name,
            s.nextStatusSymbol ?? 'x',
            s.availableAsCommand,
            newType,
        );
    });

    return { ...settings };
};

Required Steps

It would be sensible to move everything but the last line out to some function like updateAndReSaveSettings() that is called in main.ts - so that this updating is only done oncer per session, instead of once per call to getSettings().

How to Test

No response

@claremacrae claremacrae added type: internal Only regards development or contributing scope: performance issues Issues with speed or responsiveness labels Mar 25, 2024
@claremacrae claremacrae added the priority: high A high priority/important request label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high A high priority/important request scope: performance issues Issues with speed or responsiveness type: internal Only regards development or contributing
Projects
None yet
Development

No branches or pull requests

1 participant