Commit 5905a6ec authored by Stefan Brüns's avatar Stefan Brüns
Browse files

Simplify rounding of skip count

The branches can be simplified to an arithmetic operation.
parent c900324b
......@@ -497,8 +497,8 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
return img;
}
// Multiply with a high number, so we get some semi-random sequence
int skipValidItems = ((int)sequenceIndex()) * tiles * tiles;
// Advance to the next tile page each second
int skipValidItems = ((int)sequenceIndex()) * visibleCount;
img = QImage(QSize(folderWidth, folderHeight), QImage::Format_ARGB32);
img.fill(0);
......@@ -583,19 +583,13 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
break;
}
if (skipped != 0) { // Round up to full pages
const int roundedDown = (skipped / visibleCount) * visibleCount;
if (roundedDown < skipped) {
skipped = roundedDown + visibleCount;
} else {
skipped = roundedDown;
}
}
if (skipped == 0) {
break; // No valid items were found
}
// Round up to full pages
skipped = ((skipped + visibleCount - 1) / visibleCount) * visibleCount;
// We don't need to iterate again and again: Subtract any multiple of "skipped" from the count we still need to skip
skipValidItems -= (skipValidItems / skipped) * skipped;
skipped = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment