QMetaType: make all atomic operations explicit

In one case, optimize away an unnecessary extra load.

Pick-to: 6.4
Task-number: QTBUG-103834
Change-Id: Iabbf58a09627dd2fd7a40c713a878d74cb522d60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2022-04-05 08:39:19 +02:00
parent 15422d191f
commit f4b60a0850

View File

@ -104,8 +104,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();
@ -2657,7 +2658,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;