[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 57/473: Revert make fetching search results constant.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:53:47 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 9d61b9c9fb2256f2a67fdaa00e15d582bb8ab7f3
Author: Graeme Gott <graeme at gottcode.org>
Date:   Tue Jul 2 19:23:15 2013 -0400

    Revert make fetching search results constant.
---
 src/launcher.cpp    |   22 +++++++++-------------
 src/launcher.hpp    |    4 +---
 src/search_page.cpp |    4 ++--
 3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/src/launcher.cpp b/src/launcher.cpp
index 0483a04..d5a2768 100644
--- a/src/launcher.cpp
+++ b/src/launcher.cpp
@@ -174,14 +174,6 @@ Launcher::~Launcher()
 
 //-----------------------------------------------------------------------------
 
-unsigned int Launcher::get_search_results(const Query &query) const
-{
-	std::map<std::string, unsigned int>::const_iterator i = m_searches.find(query.query());
-	return (i != m_searches.end()) ? i->second : UINT_MAX;
-}
-
-//-----------------------------------------------------------------------------
-
 void Launcher::run(GdkScreen* screen) const
 {
 	const gchar* string = garcon_menu_item_get_command(m_item);
@@ -265,20 +257,23 @@ void Launcher::run(GdkScreen* screen) const
 
 //-----------------------------------------------------------------------------
 
-void Launcher::search(const Query& query)
+unsigned int Launcher::search(const Query& query)
 {
 	if (query.empty())
 	{
-		return;
+		return UINT_MAX;
 	}
 
 	// Check if search has been done or if a shorter version has failed before
 	for (std::map<std::string, unsigned int>::const_iterator i = m_searches.begin(), end = m_searches.end(); i != end; ++i)
 	{
-		if ( ((i->second == UINT_MAX) && (query.query().find(i->first) == 0))
-				|| (i->first == query.query()) )
+		if (i->first == query.query())
+		{
+			return i->second;
+		}
+		else if ((i->second == UINT_MAX) && (query.query().find(i->first) == 0))
 		{
-			return;
+			return UINT_MAX;
 		}
 	}
 
@@ -293,6 +288,7 @@ void Launcher::search(const Query& query)
 		}
 	}
 	m_searches.insert(std::make_pair(query.query(), match));
+	return match;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/src/launcher.hpp b/src/launcher.hpp
index 39fb921..df5c354 100644
--- a/src/launcher.hpp
+++ b/src/launcher.hpp
@@ -52,11 +52,9 @@ public:
 		return m_item;
 	}
 
-	unsigned int get_search_results(const Query& query) const;
-
 	void run(GdkScreen* screen) const;
 
-	void search(const Query& query);
+	unsigned int search(const Query& query);
 
 	static bool get_show_name();
 	static bool get_show_description();
diff --git a/src/search_page.cpp b/src/search_page.cpp
index 58f646d..a25000c 100644
--- a/src/search_page.cpp
+++ b/src/search_page.cpp
@@ -129,7 +129,7 @@ bool SearchPage::on_filter(GtkTreeModel* model, GtkTreeIter* iter)
 	// Check if launcher search string contains text
 	Launcher* launcher = NULL;
 	gtk_tree_model_get(model, iter, LauncherModel::COLUMN_LAUNCHER, &launcher, -1);
-	return launcher->get_search_results(m_query) != UINT_MAX;
+	return launcher->search(m_query) != UINT_MAX;
 }
 
 //-----------------------------------------------------------------------------
@@ -142,7 +142,7 @@ gint SearchPage::on_sort(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, Se
 	Launcher* launcher_b = NULL;
 	gtk_tree_model_get(model, b, LauncherModel::COLUMN_LAUNCHER, &launcher_b, -1);
 
-	return launcher_a->get_search_results(page->m_query) - launcher_b->get_search_results(page->m_query);
+	return launcher_a->search(page->m_query) - launcher_b->search(page->m_query);
 }
 
 //-----------------------------------------------------------------------------

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list