Use more QByteArrayView if applicable
According the the benchmark, QByteArrayView is the fastest class when comparing with const char *
.
#pragma GCC push_options
#pragma GCC optimize ("O0")
#include <QDebug>
#include <QElapsedTimer>
int main()
{
bool result = false;
constexpr int count = 10000000;
QElapsedTimer timer;
timer.start();
for (int i = 0; i < count;++i) {
constexpr QByteArrayView view("org.kde.plasma.wallpapers.image");
result = view == "org.kde.plasma.wallpapers.image";
}
qDebug() << timer.restart() << result;
for (int i = 0; i < count;++i) {
result = QByteArrayLiteral("org.kde.plasma.wallpapers.image") == "org.kde.plasma.wallpapers.image";
}
qDebug() << timer.restart();
for (int i = 0; i < count;++i) {
constexpr QLatin1String latin("org.kde.plasma.wallpapers.image");
result = latin == "org.kde.plasma.wallpapers.image";
}
qDebug() << timer.restart();
}
#pragma GCC pop_options