From 81bb764e9886de17260d6c7d01ff7e39c23f47f4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 3 May 2021 00:18:57 +0200 Subject: 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 Reviewed-by: Thiago Macieira --- src/corelib/global/qflags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global/qflags.h') 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)); -- cgit v1.2.3