summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-03-03 19:19:16 +0100
committerMarc Mutz <[email protected]>2025-05-21 16:57:21 +0000
commit0a9d5bd4767d2dc5900707e23790d79e6f5e0bd0 (patch)
treeb6c423c42da42f299a8f9d9f2c89e0675a20e1f5
parent8a9c2ca505c4064c530d129a53fdad18760478ee (diff)
QTriangulator: make primeForCount() safer
Move all the helpers into the function so nothing else can call them (out of contract). As a drive-by, adjust the comment to mention this is Qt 5 QHash snippets; Q6Hash is different these days. Pick-to: 6.9 6.8 6.5 Coverity-Id: 11295 Change-Id: Id1a23030e325076d81592e351dfe804742a21a87 Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--src/gui/painting/qtriangulator.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp
index 17799cb0727..03900938744 100644
--- a/src/gui/painting/qtriangulator.cpp
+++ b/src/gui/painting/qtriangulator.cpp
@@ -404,21 +404,21 @@ T QMaxHeap<T>::pop()
// QInt64Hash //
//============================================================================//
-// Copied from qhash.cpp
-static const uchar prime_deltas[] = {
- 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 17, 27, 3,
- 1, 29, 3, 21, 7, 17, 15, 9, 43, 35, 15, 0, 0, 0, 0, 0
-};
-
-// Copied from qhash.cpp
-static inline int primeForNumBits(int numBits)
-{
- return (1 << numBits) + prime_deltas[numBits];
-}
-
static inline int primeForCount(int count)
{
Q_ASSERT(count >= 0); // Q_PRE
+
+ // Copied from Qt 5 qhash.cpp
+ constexpr auto primeForNumBits = [](int numBits) -> int
+ {
+ constexpr uchar prime_deltas[] = {
+ 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 17, 27, 3,
+ 1, 29, 3, 21, 7, 17, 15, 9, 43, 35, 15, 0, 0, 0, 0, 0
+ };
+
+ return (1 << numBits) + prime_deltas[numBits];
+ };
+
int low = 0;
int high = 32;
for (int i = 0; i < 5; ++i) {