QLayoutPolicy: use qCountTrailingZeroBits() in setControlType()
This is more efficient, because it maps to a single assembler
instruction on most ISAs, and also avoids a Coverity warning about the
loop not terminating and thus 1 << i overflowing, if type == {}.
The clone class, QSizePolicy, is not affected, since it already uses
qCountTrailingZeroBits().
Amends 6c322a917a.
Coverity-Id: 474336
Pick-to: 6.5
Change-Id: Idf62d045d8ac3f0cb15196dd8664ac37d92a9cc2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d71379d447e87843c5a5d91857c4ff253ad4b847)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 4ed56eaafcc6270855b305d08d551f6a48c9667b)
bb10
parent
c0959dd287
commit
864334495d
|
|
@ -22,15 +22,7 @@ void QLayoutPolicy::setControlType(ControlType type)
|
|||
0x00000008 maps to 3
|
||||
etc.
|
||||
*/
|
||||
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (type & (0x1 << i)) {
|
||||
bits.ctype = i;
|
||||
return;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
bits.ctype = qCountTrailingZeroBits(quint32(type));
|
||||
}
|
||||
|
||||
QLayoutPolicy::ControlType QLayoutPolicy::controlType() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue