From dabc76de80e3b433a1a8e2354ca78a34389ea9f8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 10 Mar 2018 11:26:04 -0800 Subject: QSemaphore: add minor optimization for 64-bit Linux systems Since we won't use the high bit of the low 32-bit word at all, we don't need the AND with 0x7fffffff either. Just cast. Change-Id: I72f5230ad59948f784eafffd151aa5a7dee995db Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/thread/qsemaphore.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index f4674fcc1d..c2e4d7d9d1 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -140,6 +140,13 @@ static const quintptr futexNeedsWakeAllBit = static int futexAvailCounter(quintptr v) { // the low 31 bits + if (futexHasWaiterCount) { + // the high bit of the low word isn't used + Q_ASSERT((v & 0x80000000U) == 0); + + // so we can be a little faster + return int(unsigned(v)); + } return int(v & 0x7fffffffU); } -- cgit v1.2.3