summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-07-02 08:32:09 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-07-13 16:57:31 +0200
commit2b50c8bec086ae975ac5152e08f6b3dcf76306a0 (patch)
tree656fded2be7e3e7d8d7d7c9336da8e1bad0d7ac7 /examples/widgets/painting
parent1edb51a315c4ab307878d6620d8d7484cc080d09 (diff)
QObject: optimize the common case of findChildren(QString())
Outside tests, all in-tree callers of QObject::findChildren() pass no name to match, and in my experience that is also true for the vast majority of out-of-tree users. Avoid the temporary QString creation in the caller and the repeated QString::isNull() checks in the implementation by overloading findChildren() without a name argument and checking for name.isNull() only once, forking off into separate helper functions. Adjust in-tree callers that used an explicit `QString()` argument in order to pass options, which goes to show that `name` should never have been the first argument of findChilden() in the first place, even though I appreciate the symmetry with findChild() (the use-cases of which, however, are radically different). Change a `findChildren().size() == 0` call found while scanning for findChildren() calls to `!findChild()` as a drive-by. Modernize loops in the various qt_qFindChild{,ren}_helper() overloads to match how the new code looks. [ChangeLog][QtCore][QObject] Added findChildren() overload taking no name (thus optimizing this common case). Change-Id: Ifc56e5438023d079b40c67f11ae274a3e128ad5e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples/widgets/painting')
-rw-r--r--examples/widgets/painting/shared/arthurstyle.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp
index 31be899357..42afeb44c1 100644
--- a/examples/widgets/painting/shared/arthurstyle.cpp
+++ b/examples/widgets/painting/shared/arthurstyle.cpp
@@ -441,7 +441,7 @@ int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWid
void ArthurStyle::polish(QWidget *widget)
{
if (widget->layout() && qobject_cast<QGroupBox *>(widget)) {
- if (widget->findChildren<QGroupBox *>().size() == 0) {
+ if (!widget->findChild<QGroupBox *>()) {
widget->layout()->setSpacing(0);
widget->layout()->setContentsMargins(12, 12, 12, 12);
} else {