6.5.3 clean

This commit is contained in:
kleuter
2023-11-01 18:02:52 +01:00
parent bbe896803b
commit 7018d9e6c8
2170 changed files with 57471 additions and 43550 deletions

View File

@ -11,3 +11,4 @@ add_subdirectory(thread)
add_subdirectory(time)
add_subdirectory(tools)
add_subdirectory(plugin)
add_subdirectory(serialization)

View File

@ -5,6 +5,8 @@
#include <QTest>
#include <QMimeDatabase>
using namespace Qt::StringLiterals;
namespace {
struct MatchModeInfo
{
@ -51,26 +53,31 @@ void tst_QMimeDatabase::inheritsPerformance()
{
// Check performance of inherits().
// This benchmark (which started in 2009 in kmimetypetest.cpp) uses 40 mimetypes.
QStringList mimeTypes;
mimeTypes << QLatin1String("image/jpeg") << QLatin1String("image/png") << QLatin1String("image/tiff") << QLatin1String("text/plain") << QLatin1String("text/html");
mimeTypes += mimeTypes;
mimeTypes += mimeTypes;
mimeTypes += mimeTypes;
QCOMPARE(mimeTypes.size(), 40);
// (eight groups of five unique ones)
const QString uniqueMimeTypes[] = {
u"image/jpeg"_s,
u"image/png"_s,
u"image/tiff"_s,
u"text/plain"_s,
u"text/html"_s,
};
constexpr size_t NumOuterLoops = 40 / std::size(uniqueMimeTypes);
QMimeDatabase db;
QMimeType mime = db.mimeTypeForName(QString::fromLatin1("text/x-chdr"));
const QMimeType mime = db.mimeTypeForName(u"text/x-chdr"_s);
QVERIFY(mime.isValid());
QString match;
QBENCHMARK {
QString match;
foreach (const QString &mt, mimeTypes) {
if (mime.inherits(mt)) {
match = mt;
// of course there would normally be a "break" here, but we're testing worse-case
// performance here
for (size_t i = 0; i < NumOuterLoops; ++i) {
for (const QString &mt : uniqueMimeTypes) {
if (mime.inherits(mt)) {
match = mt;
// of course there would normally be a "break" here, but
// we're testing worse-case performance here
}
}
}
QCOMPARE(match, QString::fromLatin1("text/plain"));
}
QCOMPARE(match, u"text/plain"_s);
// Numbers from 2011, in release mode:
// KDE 4.7 numbers: 0.21 msec / 494,000 ticks / 568,345 instr. loads per iteration
// QMimeBinaryProvider (with Qt 5): 0.16 msec / NA / 416,049 instr. reads per iteration

View File

@ -0,0 +1,4 @@
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qcborvalue)

View File

@ -0,0 +1,10 @@
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_benchmark(tst_bench_qcborvalue
SOURCES
tst_bench_qcborvalue.cpp
LIBRARIES
Qt::Core
Qt::Test
)

View File

@ -0,0 +1,72 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QCborMap>
#include <QCborValue>
#include <QTest>
template <typename Char>
struct SampleStrings
{
static constexpr char key[] = "hello";
};
template <>
struct SampleStrings<char16_t>
{
static constexpr char16_t key[] = u"hello";
};
template <>
struct SampleStrings<QChar>
{
static const QChar *const key;
};
const QChar *const SampleStrings<QChar>::key =
reinterpret_cast<const QChar *>(SampleStrings<char16_t>::key);
template <typename T, typename = void>
constexpr bool hasValueType = false;
template <typename T>
constexpr bool hasValueType<T, std::void_t<typename T::value_type>> = true;
class tst_QCborValue : public QObject
{
Q_OBJECT
private:
template <typename Type>
void doKeyLookup();
private slots:
void keyLookupLatin1() { doKeyLookup<QLatin1StringView>(); }
void keyLookupString() { doKeyLookup<QString>(); }
void keyLookupConstCharPtr() { doKeyLookup<char>(); };
};
template <typename Type>
void tst_QCborValue::doKeyLookup()
{
const QCborMap m{{"hello", "world"}, {1, 2}};
const QCborValue v = m;
if constexpr (hasValueType<Type>) {
using Char = std::remove_cv_t<typename Type::value_type>;
using Strings = SampleStrings<Char>;
const Type s(Strings::key);
QBENCHMARK {
const QCborValue r = v[s];
Q_UNUSED(r);
}
} else {
QBENCHMARK {
const QCborValue r = v[SampleStrings<Type>::key];
Q_UNUSED(r);
}
}
}
QTEST_MAIN(tst_QCborValue)
#include "tst_bench_qcborvalue.moc"

View File

@ -1,3 +1,4 @@
// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Crimson AS <info@crimson.no>
// Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
@ -29,11 +30,7 @@ private Q_SLOTS:
static QList<QByteArray> enoughZones()
{
#ifdef EXHAUSTIVE
auto available = QTimeZone::availableTimeZoneIds();
QList<QByteArray> result;
result.reserve(available.size() + 1);
for (conat auto &name : available)
result << name;
QList<QByteArray> result = QTimeZone::availableTimeZoneIds();
#else
QList<QByteArray> result {
QByteArray("UTC"),

View File

@ -90,9 +90,9 @@ void AbstractScrollArea::setViewport(QGraphicsWidget *viewport)
if (m_viewport) {
m_viewport->setParentItem(0);
QList<QGraphicsItem*> children = m_viewport->childItems();
const QList<QGraphicsItem*> children = m_viewport->childItems();
foreach (QGraphicsItem *child, children)
for (QGraphicsItem *child : children)
child->setParentItem(0);
delete m_viewport;

View File

@ -233,13 +233,13 @@ void tst_QTableView::rowInsertion_data()
void tst_QTableView::rowInsertion()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);
QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
QTest::qWait(50);
@ -259,13 +259,13 @@ void tst_QTableView::rowRemoval_data()
void tst_QTableView::rowRemoval()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);
QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
QTest::qWait(50);
@ -282,14 +282,14 @@ void tst_QTableView::columnInsertion_data()
void tst_QTableView::columnInsertion()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);
QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);
// Same set as for rowInsertion, just swapping columns and rows.
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.left(), span.top(), span.width(), span.height());
view.show();
QTest::qWait(50);
@ -309,14 +309,14 @@ void tst_QTableView::columnRemoval_data()
void tst_QTableView::columnRemoval()
{
QFETCH(SpanList, spans);
QFETCH(const SpanList, spans);
QtTestTableModel model(10, 10);
QTableView view;
view.setModel(&model);
// Same set as for rowRemoval, just swapping columns and rows.
foreach (QRect span, spans)
for (QRect span : spans)
view.setSpan(span.left(), span.top(), span.width(), span.height());
view.show();
QTest::qWait(50);