QMetaType: don't allocate memory just to look up a key in a QHash

Use fromRawData() to create a QByteArray-as-a-view instead.

Pick-to: 6.3
Change-Id: Ic6083ec438bc089a6f11d7e4718eca72c0d51fe3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2022-04-01 11:15:03 +02:00
parent 01dab0b953
commit e191edfad0

View File

@ -2585,7 +2585,7 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
#if QT_CONFIG(thread)
Q_ASSERT(!reg->lock.tryLockForWrite());
#endif
if (auto ti = reg->aliases.value(QByteArray(typeName, length), nullptr)) {
if (auto ti = reg->aliases.value(QByteArray::fromRawData(typeName, length), nullptr)) {
return ti->typeId;
}
}