[next] telepathy-glib: base-connection: simplify add_interfaces
Xavier Claessens
xclaesse at kemper.freedesktop.org
Tue Jul 10 07:07:09 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 05ea1395d99b67e8569dd6e50ec99b782b72ea08
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=05ea1395d99b67e8569dd6e50ec99b782b72ea08
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Thu Jul 5 15:56:12 2012 +0100
base-connection: simplify add_interfaces
Calling set_size on the GArray is a little overkill.
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
telepathy-glib/base-connection.c | 18 ++----------------
1 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index 9bacd7f..1983e94 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -3193,28 +3193,14 @@ void
tp_base_connection_add_interfaces (TpBaseConnection *self,
const gchar **interfaces)
{
- guint i, n_new, size;
TpBaseConnectionPrivate *priv = self->priv;
g_return_if_fail (TP_IS_BASE_CONNECTION (self));
g_return_if_fail (self->status != TP_CONNECTION_STATUS_CONNECTED);
g_return_if_fail (self->status != TP_CONNECTION_STATUS_DISCONNECTED);
- if (interfaces == NULL || interfaces[0] == NULL)
- {
- /* If user tries to add no new interfaces, ignore it */
- return;
- }
-
- n_new = g_strv_length ((gchar **) interfaces);
- size = priv->interfaces->len;
-
- g_array_set_size (priv->interfaces, size + n_new);
- for (i = 0; i < n_new; i++)
- {
- g_array_index (priv->interfaces, const gchar *, size + i) =
- interfaces[i];
- }
+ for (; interfaces != NULL && *interfaces != NULL; interfaces++)
+ g_array_append_val (priv->interfaces, *interfaces);
}
static void
More information about the telepathy-commits
mailing list