forked from qt-creator/qt-creator
Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value that indicates whether insertion actually happened. Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include <texteditor/textmark.h>
|
||||
#include <texteditor/typingsettings.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -944,9 +945,8 @@ public:
|
||||
QString found = sel.selectedText();
|
||||
// Only add "real" completions.
|
||||
if (found.startsWith(needle)
|
||||
&& !seen.contains(found)
|
||||
&& sel.anchor() != basePosition) {
|
||||
seen.insert(found);
|
||||
&& sel.anchor() != basePosition
|
||||
&& Utils::insert(seen, found)) {
|
||||
auto item = new FakeVimAssistProposalItem(m_provider);
|
||||
item->setText(found);
|
||||
items.append(item);
|
||||
|
||||
Reference in New Issue
Block a user