diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-05-03 00:18:57 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-05-13 14:28:45 +0200 |
commit | 81bb764e9886de17260d6c7d01ff7e39c23f47f4 (patch) | |
tree | d0a0ad3431b3acadf99b85e7e70fddbacd7be438 /src/corelib/global/qflags.h | |
parent | 23780891a50ba678714f7e0a4cf43a0f8164b440 (diff) | |
download | qtbase-81bb764e9886de17260d6c7d01ff7e39c23f47f4.tar.gz |
QFlags::testFlag: code tidies
If the condition Int(flag) != 0 is false, it means that flag == 0.
So just check i against 0, which is more in line with what testFlag
behavior is documented to do.
Change-Id: Ia75fa07eee65e67a769fda7c020bf17ada77e9a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qflags.h')
-rw-r--r-- | src/corelib/global/qflags.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 82fcbdd54d..c6ecb1ea47 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -145,7 +145,7 @@ public: constexpr inline bool operator!() const noexcept { return !i; } - constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } + constexpr inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(0) ); } constexpr inline QFlags &setFlag(Enum flag, bool on = true) noexcept { return on ? (*this |= flag) : (*this &= ~QFlags(flag)); |