From 33650ac9882e92ad193eb8cb9b6e778c4a7368fc Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 7 Sep 2010 14:13:54 +0200
Subject: [PATCH] Reuse the strings

---
 src/plugins/cpptools/cpplocatorfilter.cpp |  8 ++++++++
 src/plugins/cpptools/cpplocatorfilter.h   |  4 +++-
 src/plugins/cpptools/searchsymbols.cpp    | 12 ++++++++----
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp
index 62162025d25..4dcc85599a8 100644
--- a/src/plugins/cpptools/cpplocatorfilter.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter.cpp
@@ -129,3 +129,11 @@ void CppLocatorFilter::accept(Locator::FilterEntry selection) const
     ModelItemInfo info = qvariant_cast<CppTools::Internal::ModelItemInfo>(selection.internalData);
     TextEditor::BaseTextEditor::openEditorAt(info.fileName, info.line, info.column);
 }
+
+void CppLocatorFilter::reset()
+{
+    m_searchList.clear();
+    m_previousResults.clear();
+    m_previousEntry.clear();
+    m_forceNewSearchList = true;
+}
diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h
index c58a9100c1b..e6e4e29b966 100644
--- a/src/plugins/cpptools/cpplocatorfilter.h
+++ b/src/plugins/cpptools/cpplocatorfilter.h
@@ -52,6 +52,8 @@ public:
     void accept(Locator::FilterEntry selection) const;
     void refresh(QFutureInterface<void> &future);
 
+    void reset();
+
 protected:
     SearchSymbols search;
 
@@ -64,8 +66,8 @@ private:
 
     QHash<QString, QList<ModelItemInfo> > m_searchList;
     QList<ModelItemInfo> m_previousResults;
-    bool m_forceNewSearchList;
     QString m_previousEntry;
+    bool m_forceNewSearchList;
 };
 
 } // namespace Internal
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 01aecaa236d..7ce03de8307 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -33,6 +33,7 @@
 #include <Scope.h>
 #include <Names.h>
 #include <cplusplus/LookupContext.h>
+#include <QDebug>
 
 using namespace CPlusPlus;
 using namespace CppTools::Internal;
@@ -67,8 +68,11 @@ QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString
         accept(doc->globalSymbolAt(i));
     }
     (void) switchScope(previousScope);
+    QList<ModelItemInfo> result = items;
     strings.clear();
-    return items;
+    items.clear();
+    m_paths.clear();
+    return result;
 }
 
 QString SearchSymbols::switchScope(const QString &scope)
@@ -124,7 +128,7 @@ bool SearchSymbols::visit(Function *symbol)
 
 bool SearchSymbols::visit(Namespace *symbol)
 {
-    QString name = findOrInsert(scopedSymbolName(symbol));
+    QString name = scopedSymbolName(symbol);
     QString previousScope = switchScope(name);
     for (unsigned i = 0; i < symbol->memberCount(); ++i) {
         accept(symbol->memberAt(i));
@@ -216,7 +220,7 @@ void SearchSymbols::appendItem(const QString &name,
 
     QStringList fullyQualifiedName;
     foreach (const Name *name, LookupContext::fullyQualifiedName(symbol))
-        fullyQualifiedName.append(overview.prettyName(name));
+        fullyQualifiedName.append(findOrInsert(overview.prettyName(name)));
 
     QString path = m_paths.value(symbol->fileId(), QString());
     if (path.isEmpty()) {
@@ -225,7 +229,7 @@ void SearchSymbols::appendItem(const QString &name,
     }
 
     const QIcon icon = icons.iconForSymbol(symbol);
-    items.append(ModelItemInfo(name, info, type,
+    items.append(ModelItemInfo(findOrInsert(name), findOrInsert(info), type,
                                fullyQualifiedName,
                                path,
                                symbol->line(),
-- 
GitLab