Commit 184bc28a authored by Stefan Brüns's avatar Stefan Brüns

Remove last redundant loop condition

As `skipped` is always reset to 0, the condition is always true.

Change the skipValidItems calculation to make it more obvious it
calculates the remainder, and is always a positive value.

Declare skipped inside the loop, as it is only used inside the loop.

No functional changes.
parent 5905a6ec
...@@ -518,12 +518,12 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory) ...@@ -518,12 +518,12 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
int iterations = 0; int iterations = 0;
QString hadFirstThumbnail; QString hadFirstThumbnail;
QImage firstThumbnail; QImage firstThumbnail;
int skipped = 0;
int validThumbnails = 0; int validThumbnails = 0;
while (skipped <= skipValidItems) { while (true) {
QDirIterator dir(directory, QDir::Files | QDir::Readable); QDirIterator dir(directory, QDir::Files | QDir::Readable);
int skipped = 0;
if (!dir.hasNext()) { if (!dir.hasNext()) {
break; break;
} }
...@@ -587,12 +587,11 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory) ...@@ -587,12 +587,11 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
break; // No valid items were found break; // No valid items were found
} }
// Round up to full pages // Calculate number of (partial) pages for all valid items in the directory
skipped = ((skipped + visibleCount - 1) / visibleCount) * visibleCount; auto skippedPages = (skipped + visibleCount - 1) / visibleCount;
// We don't need to iterate again and again: Subtract any multiple of "skipped" from the count we still need to skip // The sequence is continously repeated after all valid items, calculate remainder
skipValidItems -= (skipValidItems / skipped) * skipped; skipValidItems = (((int)sequenceIndex()) % skippedPages) * visibleCount;
skipped = 0;
} }
p.end(); p.end();
......
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