From c20891fabc8c3ee2251e0545878e06545b6f0cdd Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 1 Oct 2017 23:57:52 +0200 Subject: First batch --- src/selection-describer.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/selection-describer.cpp') diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 43fe1311d..5044864a4 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -15,6 +15,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include #include #include "xml/quote.h" @@ -33,16 +34,15 @@ // Returns a list of terms for the items to be used in the statusbar char* collect_terms (const std::vector &items) { - GSList *check = NULL; + std::set check; std::stringstream ss; bool first = true; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();++iter ) { SPItem *item = *iter; - if (item) { - const char *term = item->displayName(); - if (term != NULL && g_slist_find (check, term) == NULL) { - check = g_slist_prepend (check, (void *) term); + if (item && item->displayName()) { + Glib::ustring term(item->displayName()); + if (term != "" && (check.insert(term).second)) { ss << (first ? "" : ", ") << "" << term << ""; first = false; } @@ -54,14 +54,13 @@ char* collect_terms (const std::vector &items) // Returns the number of terms in the list static int count_terms (const std::vector &items) { - GSList *check = NULL; + std::set check; int count=0; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();++iter ) { SPItem *item = *iter; - if (item) { - const char *term = item->displayName(); - if (term != NULL && g_slist_find (check, term) == NULL) { - check = g_slist_prepend (check, (void *) term); + if (item && item->displayName()) { + Glib::ustring term(item->displayName()); + if (term != "" && (check.insert(term).second)) { count++; } } -- cgit v1.2.3