[eog] Avoid walking string arrays from GSettings when converting to GSLists



commit c88808f4c06872c904da52595c6f8550da87f1e3
Author: Felix Riemann <friemann gnome org>
Date:   Wed Jun 23 23:18:02 2010 +0200

    Avoid walking string arrays from GSettings when converting to GSLists
    
    The arrays are returned NULL-terminated by GSettings. Making use of this
    we don't need to walk the array first to get it's size when converting
    it to a GSList.

 src/eog-plugin-engine.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/src/eog-plugin-engine.c b/src/eog-plugin-engine.c
index 528dcb6..9700ed3 100644
--- a/src/eog-plugin-engine.c
+++ b/src/eog-plugin-engine.c
@@ -378,19 +378,16 @@ _eog_settings_get_list (GSettings   *settings,
 {
 	GSList *list = NULL;
 	gchar **values;
-	gsize len, i;
+	gsize i;
 
 	g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
 	g_return_val_if_fail (key != NULL, NULL);
 
 	values = g_settings_get_strv (settings, key);
-	len = g_strv_length (values);
-	i = 0;
 
-	while (i < len)
+	for (i = 0; values[i] != NULL; i++)
 	{
 		list = g_slist_prepend (list, values[i]);
-		i++;
 	}
 
 	g_free (values);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]