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

refactor(core/settingsgui): code cleaning #2065

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

safocl
Copy link
Contributor

@safocl safocl commented Feb 2, 2025

moving common code out of branching inside the setProfileTemp function

  • Please check if the PR fulfills these requirements
  • The changes have been tested locally
  • There are no breaking changes
  • What kind of change does this PR introduce?

cleaning of code

setProfileTemp function contains multiple lines of the common code inside the different branches of if-else

static void setProfileTemp(const enum SettingsOptions option) {
  // If in C, 5 deg, if in F 10 deg
  uint16_t temp = getSettingValue(option);
  if (getSettingValue(SettingsOptions::TemperatureInF)) {
    temp += 10;
    if (temp > MAX_TEMP_F) {
      temp = MIN_TEMP_F;
    }
    setSettingValue(option, temp); // common code
  } else {
    temp += 5;
    if (temp > MAX_TEMP_C) {
      temp = MIN_TEMP_C;
    }
    setSettingValue(option, temp); // common code
  }
}

@safocl safocl force-pushed the ref_settingsgui_clean branch 4 times, most recently from 041c2d8 to 7dcf702 Compare February 2, 2025 05:00
moving common code out of branching inside the some function.
@safocl safocl force-pushed the ref_settingsgui_clean branch from 7dcf702 to b0b22b9 Compare February 2, 2025 05:14
@ia ia added the Refactoring Changing code without adding/removing features. label Feb 2, 2025
@ia ia requested review from ia, Ralim and discip February 2, 2025 05:36
@ia ia enabled auto-merge (squash) February 2, 2025 05:44
Copy link
Collaborator

@ia ia left a comment

Choose a reason for hiding this comment

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

Good suggestion, indeed. And it seems it should work as before without breaking anything.

@ia ia merged commit ab1fa24 into Ralim:dev Feb 2, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Changing code without adding/removing features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants