From acbd04dd3daac8d8d1880f91a42282c4f7d9e0e5 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 9 Jun 2013 12:05:20 +0200 Subject: [PATCH] Improved performance of WebHistoryInterface Use std::set to search in logarithmic time. --- src/lib/history/webhistoryinterface.cpp | 4 ++-- src/lib/history/webhistoryinterface.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/history/webhistoryinterface.cpp b/src/lib/history/webhistoryinterface.cpp index 162cb9a49..45bae50d6 100644 --- a/src/lib/history/webhistoryinterface.cpp +++ b/src/lib/history/webhistoryinterface.cpp @@ -26,10 +26,10 @@ WebHistoryInterface::WebHistoryInterface(QObject* parent) void WebHistoryInterface::addHistoryEntry(const QString &url) { - m_clickedLinks.append(url); + m_clickedLinks.insert(url); } bool WebHistoryInterface::historyContains(const QString &url) const { - return m_clickedLinks.contains(url); + return m_clickedLinks.find(url) != m_clickedLinks.end(); } diff --git a/src/lib/history/webhistoryinterface.h b/src/lib/history/webhistoryinterface.h index 7610d03db..e3cb4f6a2 100644 --- a/src/lib/history/webhistoryinterface.h +++ b/src/lib/history/webhistoryinterface.h @@ -19,7 +19,7 @@ #define WEBHISTORYINTERFACE_H #include -#include +#include #include "qz_namespace.h" @@ -32,7 +32,7 @@ public: bool historyContains(const QString &url) const; private: - QStringList m_clickedLinks; + std::set m_clickedLinks; };