summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Wilmet <swilmet@gnome.org>2015-09-05 10:47:20 +0200
committerSébastien Wilmet <swilmet@gnome.org>2015-09-05 10:47:20 +0200
commit8ec9cbffdd95ef9efbc3a02a712ef69e723c007d (patch)
treef0d4f63c3d67f8a4d66369edd7793758d1eaaaa6
parente5bc293fd757d2d2f335c8d3210d76aac6a2590d (diff)
downloadgtksourceview-8ec9cbffdd95ef9efbc3a02a712ef69e723c007d.tar.gz
encoding: use g_slist_find() to simplify the code
-rw-r--r--gtksourceview/gtksourceencoding.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/gtksourceview/gtksourceencoding.c b/gtksourceview/gtksourceencoding.c
index aeb94674..40a2c188 100644
--- a/gtksourceview/gtksourceencoding.c
+++ b/gtksourceview/gtksourceencoding.c
@@ -491,21 +491,6 @@ gtk_source_encoding_get_name (const GtkSourceEncoding* enc)
return (enc->name == NULL) ? _("Unknown") : _(enc->name);
}
-static gboolean
-data_exists (GSList *list,
- const gpointer data)
-{
- for (; list != NULL; list = g_slist_next (list))
- {
- if (list->data == data)
- {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
static GSList *
strv_to_list (const gchar * const *enc_str)
{
@@ -526,7 +511,7 @@ strv_to_list (const gchar * const *enc_str)
enc = gtk_source_encoding_get_from_charset (charset);
if (enc != NULL &&
- !data_exists (res, (gpointer)enc))
+ g_slist_find (res, enc) == NULL)
{
res = g_slist_prepend (res, (gpointer)enc);
}
@@ -545,7 +530,7 @@ remove_duplicates_keep_first (GSList *list)
{
gpointer cur_encoding = l->data;
- if (!data_exists (new_list, cur_encoding))
+ if (g_slist_find (new_list, cur_encoding) == NULL)
{
new_list = g_slist_prepend (new_list, cur_encoding);
}
@@ -569,7 +554,7 @@ remove_duplicates_keep_last (GSList *list)
{
gpointer cur_encoding = l->data;
- if (!data_exists (new_list, cur_encoding))
+ if (g_slist_find (new_list, cur_encoding) == NULL)
{
new_list = g_slist_prepend (new_list, cur_encoding);
}