diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2024-11-14 15:18:37 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-11-26 16:35:55 -0800 |
| commit | cde5ce9ec6fe7eb634702578f50d2738bce3ac49 (patch) | |
| tree | e58cea4c2a0989ac6179c3668212dbae4de94fb8 /src/corelib/thread/qthread.cpp | |
| parent | 38f77d09e89c93cedf6da4144fc8aafe95975891 (diff) | |
QThreadData: make current() inline with a noexcept likely portion
This helps compilers with codegen.
Change-Id: I096db2bc39b21ee7605efffdaa257c6c658f38b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/thread/qthread.cpp')
| -rw-r--r-- | src/corelib/thread/qthread.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index f804ab8b9d3..64a6645db21 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -1119,12 +1119,16 @@ void QThread::setTerminationEnabled(bool) // No threads: so we can just use static variables Q_CONSTINIT static QThreadData *data = nullptr; -QThreadData *QThreadData::current() +QThreadData *QThreadData::currentThreadData() noexcept { - if (!data) { - data = new QThreadData; - data->thread = new QAdoptedThread(data); - } + return data; +} + +QThreadData *QThreadData::createCurrentThreadData() +{ + Q_ASSERT(!currentThreadData()); + data = new QThreadData; + data->thread = new QAdoptedThread(data); return data; } |
