After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 360121 - Bad glist usage, use g_list_prepend instead
Bad glist usage, use g_list_prepend instead
Status: RESOLVED FIXED
Product: gossip
Classification: Deprecated
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Gossip Maintainers
Gossip Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-10-06 10:52 UTC by Paolo Borelli
Modified: 2006-10-06 20:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Paolo Borelli 2006-10-06 10:52:04 UTC
in gossip_contact_copy:

	for (l = priv->groups; l; l = l->next) {
		new_priv->groups = g_list_append (new_priv->groups,
						  g_strdup (l->data));
	}

	for (l = priv->presences; l; l = l->next) {
		new_priv->presences = g_list_append (new_priv->presences,
						     g_strdup (l->data));
	}


should instead do for (...) g_list_prepend and then at the end g_list_reverse
Comment 1 Martyn Russell 2006-10-06 11:23:28 UTC
Hi Paolo :)

You are right of course. Good catch, I will fix this at some point this week when I get time, thanks.
Comment 2 Richard Hult 2006-10-06 19:33:08 UTC
If you have more than 10 groups, your group usage is very inefficient. Seriously, this is a bit silly :)
Comment 3 Paolo Borelli 2006-10-06 19:36:55 UTC
sure, but I was having fun serching for silly bugs with google codesearch and this was on the first page of http://www.google.com/codesearch?q=for+g_list_append&btnG=Search+Code

:)

Comment 4 Richard Hult 2006-10-06 19:42:46 UTC
Actually, you have a good point. People do tend to look at code and copy and paste it so we could set a good example even if it's a bit silly to try and optimize when there is no need.

Silly-comment withdrawn ;)
Comment 5 Martyn Russell 2006-10-06 20:03:15 UTC
Thank Paolo, and thanks Google for bringing this to our attention :D