Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
KIO Extras
Commits
5905a6ec
Commit
5905a6ec
authored
Aug 28, 2020
by
Stefan Brüns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify rounding of skip count
The branches can be simplified to an arithmetic operation.
parent
c900324b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
+5
-11
thumbnail/thumbnail.cpp
thumbnail/thumbnail.cpp
+5
-11
No files found.
thumbnail/thumbnail.cpp
View file @
5905a6ec
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment