QMetaType: make all atomic operations explicit

In one case, optimize away an unnecessary extra load.

Task-number: QTBUG-103834
Change-Id: Iabbf58a09627dd2fd7a40c713a878d74cb522d60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f4b60a0850ea9f67338bfd22d0847f0f0db72255)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-04-05 08:39:19 +02:00 committed by Qt Cherry-pick Bot
parent 3ddcb2b33e
commit 21c6fdf6a1

View File

@ -87,8 +87,9 @@ struct QMetaTypeCustomRegistry
#endif #endif
(ti->name); (ti->name);
if (auto ti2 = aliases.value(name)) { if (auto ti2 = aliases.value(name)) {
ti->typeId.storeRelaxed(ti2->typeId.loadRelaxed()); const auto id = ti2->typeId.loadRelaxed();
return ti2->typeId; ti->typeId.storeRelaxed(id);
return id;
} }
aliases[name] = ti; aliases[name] = ti;
int size = registry.size(); int size = registry.size();
@ -2555,7 +2556,7 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
Q_ASSERT(!reg->lock.tryLockForWrite()); Q_ASSERT(!reg->lock.tryLockForWrite());
#endif #endif
if (auto ti = reg->aliases.value(QByteArray::fromRawData(typeName, length), nullptr)) { if (auto ti = reg->aliases.value(QByteArray::fromRawData(typeName, length), nullptr)) {
return ti->typeId; return ti->typeId.loadRelaxed();
} }
} }
return QMetaType::UnknownType; return QMetaType::UnknownType;