summaryrefslogtreecommitdiffstats
path: root/src/widgets/util/qcompleter_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-04-09 10:18:39 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-27 04:35:25 +0000
commit629422607f265865cec8a010de4a5c2ffd664603 (patch)
tree73dc58f0e6ac93a052ff3785b803282726c94bfc /src/widgets/util/qcompleter_p.h
parente63daaa2acd7d7f960ff11c3130deeded92af3cc (diff)
QCompletionEngine: avoid a node allocation on lookup
In matchHint() and lookupCache(), instead of checking for the existence of 'parent' in 'cache', a new entry was created, if needed. However, the remainders of the functions could only fail in that case, so don't allocate an empty map node here at all. Wherever something sensible is added to the cache, there will have to be an insertion of the same node anyway, so there's no point doing that work here. Allows to mark these functions const. Also passed the QString argument by const-reference instead of by value. Done-with: Anton Kudryavtsev <a.kudryavtsev@netris.ru> Change-Id: Ia873f246869a68eecaef83ce4a6b6369187456be Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/util/qcompleter_p.h')
-rw-r--r--src/widgets/util/qcompleter_p.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h
index c35f70b451..a9c089ac45 100644
--- a/src/widgets/util/qcompleter_p.h
+++ b/src/widgets/util/qcompleter_p.h
@@ -150,10 +150,10 @@ public:
void filter(const QStringList &parts);
QMatchData filterHistory();
- bool matchHint(QString, const QModelIndex&, QMatchData*);
+ bool matchHint(const QString &part, const QModelIndex &parent, QMatchData *m) const;
void saveInCache(QString, const QModelIndex&, const QMatchData&);
- bool lookupCache(QString part, const QModelIndex& parent, QMatchData *m);
+ bool lookupCache(const QString &part, const QModelIndex &parent, QMatchData *m) const;
virtual void filterOnDemand(int) { }
virtual QMatchData filter(const QString&, const QModelIndex&, int) = 0;