From 4df46fd72c4c24887920a80450a9f97756430a82 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 18 Aug 2023 20:35:57 +0200 Subject: [PATCH] QRecursiveMutex: make tryLock(QDeadlineTimer) the default (was: int) The default argument staying on the old int overload meant that on Windows a nullary tryLock() call would need to go through both DLL- exported functions (int, then QDeadlineTimer) and on non-Windows platforms, it would hit the out-of-line QDeadlineTimer(qint64) ctor. By moving the default argument from the old to the new function, we reduce the nullary call on Windows from two to one exported functions. On non-Windows, we make it to hit QDeadlineTimer's constexpr inline default ctor instead. Found in API-review. Amends ff9da1db0b0963f967f45ab430ec40a3051b70b4. Change-Id: Id3e9923cf97ee1673fe05c85c30b5a12531857b3 Reviewed-by: Thiago Macieira (cherry picked from commit f780893c39d6090e804c8caeb08af4f919777109) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/thread/qmutex.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index a96db102d2a..743b86939eb 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -181,8 +181,8 @@ public: void lock() QT_MUTEX_LOCK_NOEXCEPT { tryLock(QDeadlineTimer(QDeadlineTimer::Forever)); } QT_CORE_INLINE_SINCE(6, 6) - bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT; - bool tryLock(QDeadlineTimer timer) QT_MUTEX_LOCK_NOEXCEPT; + bool tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT; + bool tryLock(QDeadlineTimer timer = {}) QT_MUTEX_LOCK_NOEXCEPT; // BasicLockable concept void unlock() noexcept;