summaryrefslogtreecommitdiff
path: root/src/terminal-app.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2015-12-02 13:56:44 +0300
committermonsta <[email protected]>2015-12-07 11:12:01 +0300
commitc2a7ef6dde4d9fc4d875988dd782acb5d0b41924 (patch)
treeb83d59f0837398463d0d394e2e2b34c89245fdd4 /src/terminal-app.c
parent78f18ad5335b5b8fca7d1039f0fd14037b716baa (diff)
downloadmate-terminal-c2a7ef6dde4d9fc4d875988dd782acb5d0b41924.tar.bz2
mate-terminal-c2a7ef6dde4d9fc4d875988dd782acb5d0b41924.tar.xz
remove excessive data conversion and don't leak string array
Diffstat (limited to 'src/terminal-app.c')
-rw-r--r--src/terminal-app.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/terminal-app.c b/src/terminal-app.c
index ab067d3..e3e23d0 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -908,7 +908,8 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
{
TerminalApp *app = TERMINAL_APP (user_data);
GVariant *val;
- GSList *strings, *tmp;
+ const gchar **strings;
+ int i;
TerminalEncoding *encoding;
const char *charset;
@@ -932,26 +933,32 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
val = g_settings_get_value (settings, key);
if (val != NULL &&
g_variant_is_of_type (val, G_VARIANT_TYPE_STRING_ARRAY))
- strings = mate_gsettings_strv_to_gslist (g_variant_get_strv (val, NULL));
+ strings = g_variant_get_strv (val, NULL);
else
strings = NULL;
- for (tmp = strings; tmp != NULL; tmp = tmp->next)
+ if (strings != NULL)
{
- charset = tmp->data;
- if (!charset)
- continue;
+ for (i = 0; strings[i] != NULL; ++i)
+ {
+ charset = strings[i];
+ if (!charset)
+ continue;
- encoding = terminal_app_ensure_encoding (app, charset);
- if (!terminal_encoding_is_valid (encoding))
- continue;
+ encoding = terminal_app_ensure_encoding (app, charset);
+ if (!terminal_encoding_is_valid (encoding))
+ continue;
- encoding->is_active = TRUE;
+ encoding->is_active = TRUE;
+ }
+
+ g_free (strings);
}
g_signal_emit (app, signals[ENCODING_LIST_CHANGED], 0);
- g_variant_unref (val);
- g_slist_free_full (strings, g_free);
+
+ if (val != NULL)
+ g_variant_unref (val);
}
static void