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 318880 - EContact does linear searches for field information
EContact does linear searches for field information
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Contacts
1.4.x (obsolete)
Other Linux
: High normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2005-10-14 17:21 UTC by Ross Burton
Modified: 2013-09-10 13:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Change from linear searches to indexing (18.40 KB, patch)
2005-10-14 17:21 UTC, Ross Burton
none Details | Review
Better patch (18.43 KB, patch)
2005-10-17 08:54 UTC, Ross Burton
needs-work Details | Review
Revised patch against HEAD (19.06 KB, patch)
2006-07-20 10:13 UTC, Ross Burton
none Details | Review
Revised (19.31 KB, patch)
2006-08-07 11:25 UTC, Ross Burton
accepted-commit_now Details | Review

Description Ross Burton 2005-10-14 17:21:26 UTC
EContact does linear searches for over field_info for field information every
time a field is accessed.  This is pretty inefficient when the key for the table
is an integer...

Attaching a patch which sorts the table into the same order as the enumeration,
so instead of doing a linear search (which is O(n)) it can lookup the data
directly (O(1)).
Comment 1 Ross Burton 2005-10-14 17:21:57 UTC
Created attachment 53479 [details] [review]
Change from linear searches to indexing
Comment 2 Ross Burton 2005-10-17 08:54:08 UTC
Created attachment 53574 [details] [review]
Better patch
Comment 3 André Klapper 2005-11-14 23:31:48 UTC
confirming and adding keyword
Comment 4 Sushma Rai 2006-01-10 10:16:04 UTC
Good one. But we can not take it now, as it breaks ABI :(
Comment 5 Ross Burton 2006-01-10 10:32:55 UTC
No it doesn't, that table is internal and not exposed: the point is that the internal table is changed to match the public listing and thus allowing an optimisation.
Comment 6 André Klapper 2006-07-08 01:07:26 UTC
sush: poke!
Comment 7 André Klapper 2006-07-15 10:10:35 UTC
sushma: poke. can we PLEASE get this in before API freeze takes place? sush, you already commented that this patch is good, please take the minutes to get this in.
Comment 8 Ross Burton 2006-07-20 09:11:37 UTC
Ping, can someone review this?

It's doesn't change ABI but does have a good performance effect, basically it does this:

-	for (i = 0; i < G_N_ELEMENTS (field_info); i ++) {
-		if (field_id == field_info[i].field_id)
-			return field_info[i].vcard_field_name;
-	}
+	return field_info[field_id].vcard_field_name;

Comment 9 Ross Burton 2006-07-20 09:41:12 UTC
Bah, this doesn't apply to current CVS.  I'll re-generate it.
Comment 10 Ross Burton 2006-07-20 10:13:44 UTC
Created attachment 69239 [details] [review]
Revised patch against HEAD
Comment 11 Devashish Sharma 2006-07-24 10:40:23 UTC
reviewed , Ross commit this please.
Just check once again if there are any other places where this new logic (changing from for loop to direct indexing) can be applied.
Also make sure nothing has been left out from field_info, i have checked this but please double check.
Comment 12 André Klapper 2006-08-01 21:10:14 UTC
ross: ping :-)
Comment 13 Ross Burton 2006-08-07 11:25:00 UTC
Created attachment 70378 [details] [review]
Revised

New patch incorporating the GaduGadu change.  Is it too late to commit?
Comment 14 Harish Krishnaswamy 2006-08-07 12:38:14 UTC
Devashish ?
Comment 15 Devashish Sharma 2006-08-07 12:50:31 UTC
Looks good, commit it please.
Comment 16 Harish Krishnaswamy 2006-08-07 13:11:48 UTC
Added ChangeLog and committed. Thanks for the patch.