Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ void Settings::setNewResolutionList()
QStringList resolutiontemp1 = resolutionDatabase[j].split("x");
QStringList resolutiontemp2 = resolutionDatabase[j + 1].split("x");

if ((resolutiontemp1[0].toInt() <= resolutiontemp2[0].toInt())
|| (resolutiontemp1[1].toInt() < resolutiontemp2[1].toInt())) {
if ((resolutiontemp1[0].toInt() < resolutiontemp2[0].toInt()) ||
(resolutiontemp1[0].toInt() == resolutiontemp2[0].toInt() && (resolutiontemp1[1].toInt() < resolutiontemp2[1].toInt()))) {
Comment on lines +139 to +140
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid repeated toInt() calls and simplify the comparison expression.

Extract the int values before the condition and compare those instead:

int w1 = resolutiontemp1[0].toInt();
int h1 = resolutiontemp1[1].toInt();
int w2 = resolutiontemp2[0].toInt();
int h2 = resolutiontemp2[1].toInt();

if (w1 < w2 || (w1 == w2 && h1 < h2)) {
    ...
}

This avoids repeated conversions inside the loop and makes the sort logic easier to follow.

QString resolutionstr = resolutionDatabase[j + 1];
resolutionDatabase[j + 1] = resolutionDatabase[j];
resolutionDatabase[j] = resolutionstr;
Expand Down
Loading