From 08adcc62a76b39401c91cbfa7e9f721f0aa5b7f6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 29 Dec 2015 14:35:34 +0100 Subject: [PATCH] QComboBox: use NRVO from QAIM::match() and prevent a detach attempt Receiving the QStringList return value through RVO instead of move-assigning it saves 48b in text size on optimized GCC 4.9 Linux AMD 64 builds. Marking the QStringList const saves another 112b because the following first() doesn't need to attempt a detach. Change-Id: If6f25399e80de12114ce41c557bff6ee8c24938b Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qcombobox.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 565fc7c428..c442ace476 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1548,9 +1548,8 @@ void QComboBox::setDuplicatesEnabled(bool enable) int QComboBox::findData(const QVariant &data, int role, Qt::MatchFlags flags) const { Q_D(const QComboBox); - QModelIndexList result; QModelIndex start = d->model->index(0, d->modelColumn, d->root); - result = d->model->match(start, role, data, 1, flags); + const QModelIndexList result = d->model->match(start, role, data, 1, flags); if (result.isEmpty()) return -1; return result.first().row();