[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 05/20: Use copy elision.

noreply at xfce.org noreply at xfce.org
Thu Feb 6 12:03:22 CET 2020


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

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 1b97bee8af60f43c24bef17354fc5282ae991586
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Feb 1 14:01:04 2020 -0500

    Use copy elision.
---
 panel-plugin/favorites-page.cpp | 11 ++++++-----
 panel-plugin/favorites-page.h   |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/panel-plugin/favorites-page.cpp b/panel-plugin/favorites-page.cpp
index b5e5bf3..70f0b0c 100644
--- a/panel-plugin/favorites-page.cpp
+++ b/panel-plugin/favorites-page.cpp
@@ -219,8 +219,10 @@ void FavoritesPage::on_row_deleted(GtkTreeModel*, GtkTreePath* path)
 
 //-----------------------------------------------------------------------------
 
-void FavoritesPage::sort(std::vector<Launcher*>& items) const
+std::vector<Launcher*> FavoritesPage::sort() const
 {
+	std::vector<Launcher*> items;
+	items.reserve(wm_settings->favorites.size());
 	for (const auto& favorite : wm_settings->favorites)
 	{
 		Launcher* launcher = get_window()->get_applications()->get_application(favorite);
@@ -231,14 +233,14 @@ void FavoritesPage::sort(std::vector<Launcher*>& items) const
 		items.push_back(launcher);
 	}
 	std::sort(items.begin(), items.end(), &Element::less_than);
+	return items;
 }
 
 //-----------------------------------------------------------------------------
 
 void FavoritesPage::sort_ascending()
 {
-	std::vector<Launcher*> items;
-	sort(items);
+	const std::vector<Launcher*> items = sort();
 
 	wm_settings->favorites.clear();
 	for (auto launcher : items)
@@ -253,8 +255,7 @@ void FavoritesPage::sort_ascending()
 
 void FavoritesPage::sort_descending()
 {
-	std::vector<Launcher*> items;
-	sort(items);
+	const std::vector<Launcher*> items = sort();
 
 	wm_settings->favorites.clear();
 	for (std::vector<Launcher*>::const_reverse_iterator i = items.rbegin(), end = items.rend(); i != end; ++i)
diff --git a/panel-plugin/favorites-page.h b/panel-plugin/favorites-page.h
index 16f19b2..9af38ee 100644
--- a/panel-plugin/favorites-page.h
+++ b/panel-plugin/favorites-page.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2019 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@ private:
 	void on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
 	void on_row_inserted(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
 	void on_row_deleted(GtkTreeModel*, GtkTreePath* path);
-	void sort(std::vector<Launcher*>& items) const;
+	std::vector<Launcher*> sort() const;
 	void sort_ascending();
 	void sort_descending();
 	void view_created();

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


More information about the Xfce4-commits mailing list