diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2022-11-04 18:42:18 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2022-12-07 15:03:03 +0200 |
commit | 9d9c25e2142f1933a89e30fca1fd604a6a0ab7c2 (patch) | |
tree | ca8b90dc1a4b743329fab90bb6f6fd8ed20b9316 /tests/auto/testlib | |
parent | 83be948833918ae04ed2c8f1cfd48589ac200b37 (diff) |
Use QString/QByteArray range erase()
Change-Id: I0fb81306ebe8fc7acd63bb62dc6720c734461da0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r-- | tests/auto/testlib/selftests/tst_selftests.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index f6c97bc345..2265fe3147 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -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 |