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 335375 - bad use of GList in stickynotes applet
bad use of GList in stickynotes applet
Status: RESOLVED FIXED
Product: gnome-applets
Classification: Other
Component: stickynotes
unspecified
Other Linux
: High normal
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-21 16:19 UTC by Paolo Borelli
Modified: 2010-01-24 01:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.53 KB, patch)
2006-03-21 17:15 UTC, Paolo Borelli
accepted-commit_now Details | Review

Description Paolo Borelli 2006-03-21 16:19:43 UTC
despite its innocent look, the following code is *not* a good idea:

	for (i = 0; i < g_list_length(stickynotes->notes) && !inconsistent; i++) {
		StickyNote *note = g_list_nth_data(stickynotes->notes, i);

using the good old

	for (l = stickynotes->notes; l != NULL && !inconsistent; l = l->next) {
		StickyNote *note = l->data

avoids N^3 behavior.


(not sure it's measurable given people do not have a bazillion notes, but still...)
Comment 1 Paolo Borelli 2006-03-21 16:23:41 UTC
(erm, typo, I mean O(N^2))
Comment 2 Danielle Madeley 2006-03-21 16:54:14 UTC
Damnit, I thought I'd got all of these. It seems that some number slipped through. Did you want to cook a patch for it?
Comment 3 Paolo Borelli 2006-03-21 17:15:42 UTC
Created attachment 61706 [details] [review]
patch

here is the patch, however it's not even compile tested (I don't have a full jhbuild set up at the moment)

apart from the list loops I also moved the var declarations before the gconf functions to keep old compilers happy.
Comment 4 Danielle Madeley 2006-04-14 17:04:39 UTC
This patch looks fundamentally correct, did you want to test it and commit it?
Comment 5 Danielle Madeley 2006-05-28 14:35:24 UTC
In gnome-2-14, needs committing to HEAD.
Comment 6 Kjartan Maraas 2006-07-02 10:27:58 UTC
I commited this to HEAD.