Prepend to lists rather than append as that's more efficient.

svn path=/trunk/; revision=52650
This commit is contained in:
Anders Broman 2013-10-16 20:02:14 +00:00
parent fe55299806
commit 26ad68d45b
4 changed files with 14 additions and 13 deletions

View File

@ -384,7 +384,7 @@ if_info_add_address(if_info_t *if_info, struct sockaddr *addr)
if_addr->ifat_type = IF_AT_IPv4;
if_addr->addr.ip4_addr =
*((guint32 *)&(ai->sin_addr.s_addr));
if_info->addrs = g_slist_append(if_info->addrs, if_addr);
if_info->addrs = g_slist_prepend(if_info->addrs, if_addr);
break;
#ifdef INET6
@ -395,7 +395,7 @@ if_info_add_address(if_info_t *if_info, struct sockaddr *addr)
memcpy((void *)&if_addr->addr.ip6_addr,
(void *)&ai6->sin6_addr.s6_addr,
sizeof if_addr->addr.ip6_addr);
if_info->addrs = g_slist_append(if_info->addrs, if_addr);
if_info->addrs = g_slist_prepend(if_info->addrs, if_addr);
break;
#endif
}

View File

@ -86,11 +86,11 @@ static void append_remote_list(GList *iflist)
temp_addr = NULL;
}
if (temp_addr) {
temp->addrs = g_slist_append(temp->addrs, temp_addr);
temp->addrs = g_slist_prepend(temp->addrs, temp_addr);
}
}
temp->loopback = if_info->loopback;
iflist = g_list_append(iflist, temp);
iflist = g_list_prepend(iflist, temp);
}
}
#endif
@ -177,14 +177,14 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
if_addr = NULL;
}
if (if_addr) {
if_info->addrs = g_slist_append(if_info->addrs, if_addr);
if_info->addrs = g_slist_prepend(if_info->addrs, if_addr);
}
}
if (strcmp(if_parts[5], "loopback") == 0)
if_info->loopback = TRUE;
g_strfreev(if_parts);
g_strfreev(addr_parts);
if_list = g_list_append(if_list, if_info);
if_list = g_list_prepend(if_list, if_info);
}
g_strfreev(raw_list);
@ -293,7 +293,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
else
data_link_info->description = NULL;
linktype_list = g_list_append(linktype_list, data_link_info);
linktype_list = g_list_prepend(linktype_list, data_link_info);
}
g_strfreev(raw_list);
@ -334,11 +334,11 @@ void add_interface_to_remote_list(if_info_t *if_info)
temp_addr = NULL;
}
if (temp_addr) {
temp->addrs = g_slist_append(temp->addrs, temp_addr);
temp->addrs = g_slist_prepend(temp->addrs, temp_addr);
}
}
temp->loopback = if_info->loopback;
remote_interface_list = g_list_append(remote_interface_list, temp);
remote_interface_list = g_list_prepend(remote_interface_list, temp);
}
#endif
#endif /* HAVE_LIBPCAP */

View File

@ -122,7 +122,7 @@ color_filters_add_tmp(GSList **cfl)
colorf = color_filter_new(name, NULL, &bg_color, &fg_color, TRUE);
colorf->filter_text = g_strdup("frame");
colorf->c_colorfilter = NULL;
*cfl = g_slist_append(*cfl, colorf);
*cfl = g_slist_prepend(*cfl, colorf);
g_free(name);
}
@ -269,7 +269,7 @@ color_filter_list_clone_cb(gpointer filter_arg, gpointer cfl_arg)
color_filter_t *new_colorf;
new_colorf = color_filter_clone((color_filter_t *)filter_arg);
*cfl = g_slist_append(*cfl, new_colorf);
*cfl = g_slist_prepend(*cfl, new_colorf);
}
/* clone the specified list */
@ -604,7 +604,7 @@ read_filters_file(FILE *f, gpointer user_data)
/* internal call */
colorf->c_colorfilter = temp_dfilter;
*cfl = g_slist_append(*cfl, colorf);
*cfl = g_slist_prepend(*cfl, colorf);
} else {
/* external call */
/* just editing, don't need the compiled filter */

View File

@ -60,8 +60,9 @@ function_dup(gconstpointer data)
for (p = org->params; p; p = p->next) {
const stnode_t *param = (const stnode_t *)p->data;
stfuncrec->params = g_slist_append(stfuncrec->params, stnode_dup(param));
stfuncrec->params = g_slist_prepend(stfuncrec->params, stnode_dup(param));
}
stfuncrec->params = g_slist_reverse(stfuncrec->params);
return (gpointer) stfuncrec;
}