[geany/geany] 684c18: Simplify the filtering code a bit and follow Geany style

Jiří Techet git-noreply at xxxxx
Thu Jan 13 14:48:31 UTC 2022


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Thu, 13 Jan 2022 14:48:31 UTC
Commit:      684c189bf2910c20d21f830dc14a91ecc8c66472
             https://github.com/geany/geany/commit/684c189bf2910c20d21f830dc14a91ecc8c66472

Log Message:
-----------
Simplify the filtering code a bit and follow Geany style


Modified Paths:
--------------
    src/symbols.c

Modified: src/symbols.c
39 lines changed, 16 insertions(+), 23 deletions(-)
===================================================================
@@ -320,49 +320,42 @@ static GList *get_tag_list(GeanyDocument *doc, TMTagType tag_types)
 {
 	GList *tag_names = NULL;
 	guint i, j;
-
-	GtkEntry  *tfentry = NULL; // entry_tagfilter
-	gchar    **tfarray = NULL; // Array of the Tag Filter
-	guint      tfarlen = 0;    // Length of the tfarray
-	gboolean   tfapres = TRUE; // Result of the Tag Filter Applying
+	GtkEntry *tf_entry;
+	gchar **tf_strv;
 
 	g_return_val_if_fail(doc, NULL);
 
 	if (! doc->tm_file || ! doc->tm_file->tags_array)
 		return NULL;
 
-	tfentry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter"));
-	tfarray = g_strsplit_set(gtk_entry_get_text(tfentry), " ", -1);
-	tfarlen = g_strv_length(tfarray);
+	tf_entry = GTK_ENTRY(ui_lookup_widget(main_widgets.window, "entry_tagfilter"));
+	tf_strv = g_strsplit_set(gtk_entry_get_text(tf_entry), " ", -1);
 
 	for (i = 0; i < doc->tm_file->tags_array->len; ++i)
 	{
 		TMTag *tag = TM_TAG(doc->tm_file->tags_array->pdata[i]);
 
-		if (G_UNLIKELY(tag == NULL))
-			return NULL;
-
 		if (tag->type & tag_types)
 		{
-			tfapres = TRUE;
-			for (j = 0; j < tfarlen; j++)
+			gboolean filtered = FALSE;
+			gchar **val;
+
+			foreach_strv(val, tf_strv)
 			{
-				if (tfarray[j][0] != '\0')
+				if (strstr(tag->name, *val) == NULL)
 				{
-					if (g_strrstr(tag->name, tfarray[j]) == NULL)
-					{
-						tfapres = FALSE;
-						break;
-					}
+					filtered = TRUE;
+					break;
 				}
 			}
-			if (tfapres) tag_names = g_list_prepend(tag_names, tag);
+			if (!filtered)
+				tag_names = g_list_prepend(tag_names, tag);
 		}
 	}
 	tag_names = g_list_sort(tag_names, compare_symbol_lines);
-	
-	g_strfreev(tfarray);
-	
+
+	g_strfreev(tf_strv);
+
 	return tag_names;
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list