imageFormatsForMimeType: port to QBAV

to reduce allocations

Change-Id: Ic48616d0627cb1dfee5f844bee263a59a430d9ba
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Anton Kudryavtsev 2023-08-28 17:42:26 +03:00 committed by Anton Kudryavtsev
parent cf066f7d03
commit b770b0f8b9
2 changed files with 3 additions and 3 deletions

View File

@ -113,11 +113,11 @@ QList<QByteArray> supportedMimeTypes(Capability cap)
return mimeTypes;
}
QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType, Capability cap)
QList<QByteArray> imageFormatsForMimeType(QByteArrayView mimeType, Capability cap)
{
QList<QByteArray> formats;
if (mimeType.startsWith("image/")) {
const QByteArray type = mimeType.mid(sizeof("image/") - 1);
const QByteArrayView type = mimeType.mid(sizeof("image/") - 1);
for (const auto &fmt : _qt_BuiltInFormats) {
if (fmt.mimeType == type && !formats.contains(fmt.extension))
formats << fmt.extension;

View File

@ -94,7 +94,7 @@ enum Capability {
};
QList<QByteArray> supportedImageFormats(Capability cap);
QList<QByteArray> supportedMimeTypes(Capability cap);
QList<QByteArray> imageFormatsForMimeType(const QByteArray &mimeType, Capability cap);
QList<QByteArray> imageFormatsForMimeType(QByteArrayView mimeType, Capability cap);
}