summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-24 17:03:26 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-24 17:03:26 (GMT)
commita1de48d6fd0dcde23da5d8bbbb4cbff9378a6996 (patch)
tree74cf094bc268d9869beda8b12b62737c1bb8d8e0
parenta2d7536689bdeb50780c3f0af7ece6c4488cc1d0 (diff)
less linear search in lists
-rw-r--r--src/utils/kateglobal.cpp19
-rw-r--r--src/utils/kateglobal.h40
2 files changed, 26 insertions, 33 deletions
diff --git a/src/utils/kateglobal.cpp b/src/utils/kateglobal.cpp
index 83cf685..1f76947 100644
--- a/src/utils/kateglobal.cpp
+++ b/src/utils/kateglobal.cpp
@@ -244,11 +244,6 @@ KTextEditor::Document *KTextEditor::EditorPrivate::createDocument(QObject *paren
return doc;
}
-QList<KTextEditor::Document *> KTextEditor::EditorPrivate::documents()
-{
- return m_docs;
-}
-
//BEGIN KTextEditor::Editor config stuff
void KTextEditor::EditorPrivate::readConfig(KConfig *config)
{
@@ -482,24 +477,26 @@ KTextEditor::EditorPrivate *KTextEditor::EditorPrivate::self()
void KTextEditor::EditorPrivate::registerDocument(KTextEditor::DocumentPrivate *doc)
{
- m_documents.append(doc);
- m_docs.append(doc);
+ Q_ASSERT (!m_documents.contains(doc));
+ m_documents.insert(doc, doc);
}
void KTextEditor::EditorPrivate::deregisterDocument(KTextEditor::DocumentPrivate *doc)
{
- m_docs.removeAll(doc);
- m_documents.removeAll(doc);
+ Q_ASSERT (m_documents.contains(doc));
+ m_documents.remove(doc);
}
void KTextEditor::EditorPrivate::registerView(KTextEditor::ViewPrivate *view)
{
- m_views.append(view);
+ Q_ASSERT (!m_views.contains(view));
+ m_views.insert(view);
}
void KTextEditor::EditorPrivate::deregisterView(KTextEditor::ViewPrivate *view)
{
- m_views.removeAll(view);
+ Q_ASSERT (m_views.contains(view));
+ m_views.remove(view);
}
//BEGIN command interface
diff --git a/src/utils/kateglobal.h b/src/utils/kateglobal.h
index c8b6ff1..1b2a5d6 100644
--- a/src/utils/kateglobal.h
+++ b/src/utils/kateglobal.h
@@ -110,7 +110,10 @@ public:
* Returns a list of all documents of this editor.
* @return list of all existing documents
*/
- QList<KTextEditor::Document *> documents();
+ QList<KTextEditor::Document *> documents()
+ {
+ return m_documents.keys();
+ }
/**
* Set the global application object.
@@ -226,21 +229,12 @@ public:
void deregisterView(KTextEditor::ViewPrivate *view);
/**
- * return a list of all registered docs
- * @return all known documents
- */
- QList<KTextEditor::DocumentPrivate *> &kateDocuments()
- {
- return m_documents;
- }
-
- /**
* return a list of all registered views
* @return all known views
*/
- QList<KTextEditor::ViewPrivate *> &views()
+ QList<KTextEditor::ViewPrivate *> views()
{
- return m_views;
+ return m_views.toList();
}
/**
@@ -407,6 +401,15 @@ public:
return m_clipboardHistory;
}
+ /**
+ * return a list of all registered docs
+ * @return all known documents
+ */
+ QList<KTextEditor::DocumentPrivate *> kateDocuments()
+ {
+ return m_documents.values();
+ }
+
Q_SIGNALS:
/**
* Emitted if the history of clipboard changes via copyToClipboard
@@ -426,14 +429,14 @@ private:
KAboutData m_aboutData;
/**
- * registered docs
+ * registered docs, map from general to specialized pointer
*/
- QList<KTextEditor::DocumentPrivate *> m_documents;
+ QHash<KTextEditor::Document *, KTextEditor::DocumentPrivate *> m_documents;
/**
* registered views
*/
- QList<KTextEditor::ViewPrivate *> m_views;
+ QSet<KTextEditor::ViewPrivate *> m_views;
/**
* global dirwatch object
@@ -500,19 +503,12 @@ private:
*/
KateSpellCheckManager *m_spellCheckManager;
- QList<KTextEditor::Document *> m_docs;
-
/**
* global instance of the simple word completion mode
*/
KateWordCompletionModel *m_wordCompletionModel;
/**
- * session config
- */
- KSharedConfig::Ptr m_sessionConfig;
-
- /**
* clipboard history
*/
QStringList m_clipboardHistory;