-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.5.0
-
None
From
https://bugs.kde.org/show_bug.cgi?id=361691
#include <QString>
#include <QDebug>
#define N 100000000
bool testQStringLiteral()
{
qDebug() << "QStringLiteral";
bool result = false;
QString s;
for (int i = 0; i < N; ++i)
{
result |= s.contains(QStringLiteral("foo"));
}
return result;
}
bool testQLatin1String()
{
qDebug() << "QLatin1String";
bool result = false;
QString s;
for (int i = 0; i < N; ++i)
{
result |= s.contains(QLatin1String("foo"));
}
return result;
}
int main(int argv, char **)
{
if (argv == 1) {
return testQLatin1String();
} else {
return testQStringLiteral();
}
}
$ time ./qttester QLatin1String real 0m1.450s user 0m1.448s sys 0m0.004s $ time ./qttester 1 QStringLiteral real 0m0.655s user 0m0.652s sys 0m0.000s
Are the current guidelines about when to use QLatin1String and QStringLiteral in line with this? I thought QLatin1String should be used when an overload for it exists.
Or is this a QString bug?
| For Gerrit Dashboard: QTBUG-52617 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 156181,3 | QString: Avoid searching for a needle which is longer than the hay | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |