From 9daf344c8d403c96789f7f041865cd6d181c2065 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Jun 2024 14:08:48 -0700 Subject: QLibrary: move prefixes_sys() to the header and make it prefix_sys() There's only one prefix for Unix ("lib") and none for Windows, so there's no need to allocate a QList for it in this function. For one of the two callers, it was also possible to avoid the QList and QString allocations, at the expense of testing the same file twice on Windows. We can't do the same for Unix systems because we may add more elements to the QList. Change-Id: Ic0adfa808d28487a8303fffd17d9e6d35aaa79f4 Reviewed-by: Fabian Kosmale --- src/corelib/plugin/qpluginloader.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/corelib/plugin/qpluginloader.cpp') diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 03b8cfbb848..df154f7e8dd 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -229,8 +229,7 @@ static QString locatePlugin(const QString& fileName) return fi.canonicalFilePath(); } } - QStringList prefixes = QLibraryPrivate::prefixes_sys(); - prefixes.prepend(QString()); + std::array prefixes = { QStringView(), QLibraryPrivate::prefix_sys() }; QStringList suffixes = QLibraryPrivate::suffixes_sys(QString()); suffixes.prepend(QString()); @@ -247,7 +246,7 @@ static QString locatePlugin(const QString& fileName) } for (const QString &path : std::as_const(paths)) { - for (const QString &prefix : std::as_const(prefixes)) { + for (QStringView prefix : prefixes) { for (const QString &suffix : std::as_const(suffixes)) { #ifdef Q_OS_ANDROID { -- cgit v1.2.3