[libsoup/wip/tpopela/negotiate] Improve the parse_trusted_uris function
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/tpopela/negotiate] Improve the parse_trusted_uris function
- Date: Sat, 6 Feb 2016 15:46:41 +0000 (UTC)
commit 0606a1ec3e5964e66759d87b88179866f4383191
Author: Tomas Popela <tpopela redhat com>
Date: Sat Feb 6 15:36:44 2016 +0100
Improve the parse_trusted_uris function
Avoid g_strv_length calls on every iteration of the loop going through
parsed URIs. Also use the g_slist_prepend instead of g_slist_append as the
order doesn't matter.
libsoup/soup-auth-negotiate.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-auth-negotiate.c b/libsoup/soup-auth-negotiate.c
index d903bdb..5130bec 100644
--- a/libsoup/soup-auth-negotiate.c
+++ b/libsoup/soup-auth-negotiate.c
@@ -304,6 +304,7 @@ parse_trusted_uris (void)
gchar **uris = NULL;
const gchar *env;
gint i;
+ guint length;
/* Initialize the list */
trusted_uris = NULL;
@@ -314,12 +315,13 @@ parse_trusted_uris (void)
if (!(uris = g_strsplit (env, ",", -1)))
return;
- for (i = 0; i < g_strv_length (uris); i++) {
+ length = g_strv_length (uris);
+ for (i = 0; i < length; i++) {
SoupURI *uri;
/* If the supplied URI is valid, append it to the list */
if ((uri = soup_uri_new (uris[i])))
- trusted_uris = g_slist_append (trusted_uris, uri);
+ trusted_uris = g_slist_prepend (trusted_uris, uri);
}
g_strfreev (uris);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]