diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-12 20:56:23 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-18 11:06:29 +0100 |
commit | fe6338bded8fa595b12ed1ba991cf6e510cd1cc3 (patch) | |
tree | a107a153077a4e660423749f45986e7cbb7e531f /src/corelib/kernel/qmetatype.cpp | |
parent | 51e50bd1e66b2ba30619e9d6b388261c2622b37e (diff) |
QMetaType::id: add fastpath
This inlines the fastpath of QMetaType::id and splits the slowpath into
its own function. With that change, we can also use id in operator==,
simplifying the code there.
Change-Id: I286fe173b43a495dbda8faa151a93895b4fd22e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 71fcc6d407..8ee37212ee 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -487,15 +487,17 @@ bool QMetaType::isRegistered() const Returns id type hold by this QMetatype instance. */ -int QMetaType::id() const + +/*! + \internal + The slowpath of id(). Precondition: d_ptr != nullptr +*/ +int QMetaType::idHelper() const { - if (d_ptr) { - if (int id = d_ptr->typeId.loadRelaxed()) - return id; - auto reg = customTypeRegistry(); - if (reg) { - return reg->registerCustomType(d_ptr); - } + Q_ASSERT(d_ptr); + auto reg = customTypeRegistry(); + if (reg) { + return reg->registerCustomType(d_ptr); } return 0; } |