Use QString/QByteArray range erase()
Change-Id: I0fb81306ebe8fc7acd63bb62dc6720c734461da0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
83be948833
commit
9d9c25e214
|
|
@ -3016,8 +3016,7 @@ void tst_QString::append_special_cases()
|
|||
|
||||
{
|
||||
QString a = "onetwothree";
|
||||
while (a.size() - 1)
|
||||
a.remove(0, 1);
|
||||
a.erase(a.cbegin(), std::prev(a.cend()));
|
||||
QCOMPARE(a.append(u'b'), QString("eb"));
|
||||
}
|
||||
}
|
||||
|
|
@ -3705,7 +3704,7 @@ void tst_QString::remove_extra()
|
|||
QString s = "BCDEFGHJK";
|
||||
QString s1 = s;
|
||||
s1.insert(0, u'A'); // detaches
|
||||
s1.remove(0, 1);
|
||||
s1.erase(s1.cbegin());
|
||||
QCOMPARE(s1, s);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -459,11 +459,13 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error)
|
|||
// This code avoids using a QRegExp because QRegExp might be broken.
|
||||
// Sample format: 4,000 msec per iteration (total: 4,000, iterations: 1)
|
||||
|
||||
QString sFirstNumber;
|
||||
while (!remaining.isEmpty() && !remaining.at(0).isSpace()) {
|
||||
sFirstNumber += remaining.at(0);
|
||||
remaining.remove(0,1);
|
||||
}
|
||||
const auto begin = remaining.cbegin();
|
||||
auto it = std::find_if(begin, remaining.cend(), [](const auto ch) {
|
||||
return ch.isSpace();
|
||||
});
|
||||
QString sFirstNumber{std::distance(begin, it), Qt::Uninitialized};
|
||||
std::move(begin, it, sFirstNumber.begin());
|
||||
remaining.erase(begin, it);
|
||||
remaining = remaining.trimmed();
|
||||
|
||||
// 4,000 -> 4000
|
||||
|
|
|
|||
Loading…
Reference in New Issue