Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qprimefornumbits_p.h
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
ifndef
QPRIMEFORNUMBITS_P_H
6
#
define
QPRIMEFORNUMBITS_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
private
/
qtqmlglobal_p
.
h
>
20
21
QT_BEGIN_NAMESPACE
22
23
/*
24
The prime_deltas array is a table of selected prime values, even
25
though it doesn't look like one. The primes we are using are 1,
26
2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate
27
surrounding of a power of two.
28
29
The qPrimeForNumBits() function returns the prime associated to a
30
power of two. For example, qPrimeForNumBits(8) returns 257.
31
*/
32
33
inline
int
qPrimeForNumBits
(
int
numBits)
34
{
35
static
constexpr
const
uchar prime_deltas[] = {
36
0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
37
1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
38
};
39
40
return
(1 << numBits) + prime_deltas[numBits];
41
}
42
43
QT_END_NAMESPACE
44
45
#
endif
// QPRIMEFORNUMBITS_P_H
qPrimeForNumBits
QT_BEGIN_NAMESPACE int qPrimeForNumBits(int numBits)
Definition
qprimefornumbits_p.h:33
qtdeclarative
src
qml
qml
ftw
qprimefornumbits_p.h
Generated on
for Qt by
1.16.1