From 0b334ce4e863b227054237beb3d4064e7893f3b6 Mon Sep 17 00:00:00 2001 From: monsta Date: Wed, 2 Dec 2015 13:11:19 +0300 Subject: [PATCH] simplify some code, get rid of excessive data conversions --- src/terminal-util.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/terminal-util.c b/src/terminal-util.c index 320afd1..cc14584 100644 --- a/src/terminal-util.c +++ b/src/terminal-util.c @@ -37,8 +37,6 @@ #include #endif -#include - #include "terminal-accels.h" #include "terminal-app.h" #include "terminal-intl.h" @@ -606,30 +604,23 @@ static void setup_ignore_host_env (GHashTable *env_table, GSettings *settings) { - GSList *ignore; - gchar **ignore_strv = g_settings_get_strv (settings, "ignore-hosts"); + gchar **ignore = g_settings_get_strv (settings, "ignore-hosts"); + if (ignore == NULL) + return; - ignore = mate_gsettings_strv_to_gslist ((const gchar *const *)ignore_strv); - if (ignore) + GString *buf = g_string_sized_new (64); + int i; + + for (i = 0; ignore[i] != NULL; ++i) { - GString *buf = g_string_sized_new (64); - while (ignore != NULL) - { - GSList *old; - - if (buf->len) - g_string_append_c (buf, ','); - g_string_append (buf, ignore->data); - - old = ignore; - ignore = g_slist_next (ignore); - g_free (old->data); - g_slist_free_1 (old); - } - set_proxy_env (env_table, "no_proxy", g_string_free (buf, FALSE)); + if (buf->len) + g_string_append_c (buf, ','); + g_string_append (buf, ignore[i]); } - if (ignore_strv) - g_strfreev(ignore_strv); + + set_proxy_env (env_table, "no_proxy", g_string_free (buf, FALSE)); + + g_strfreev(ignore); } static void