GNOME Bugzilla – Bug 695648
Utils: add a fast-path for empty sets and multimaps
Last modified: 2013-03-13 12:59:41 UTC
Created attachment 238611 [details] [review] collection comparators: optimize the case of empty collections Comparing integers is a lot faster than constructing one or more GObjects to iterate over the hash table. This saves about 3% of the user CPU time needed to deal with 2049 simple e-d-s Google contacts, each with one email address and no phone numbers etc.
Review of attachment 238611 [details] [review]: Would be useful to add a note that the zero comparison is to avoid creating an iterator. Apart from that, this looks like a handy optimisation. Please commit to master!
(In reply to comment #1) > Please commit to master! *remembering to update NEWS.
Unfortunately, this makes a couple of the e-d-s tests time out. Looking into it...
Created attachment 238719 [details] [review] collection comparators: optimize the case of empty collections Comparing integers is a lot faster than constructing one or more GObjects to iterate over the hash table. This saves about 3% of the user CPU time needed to deal with 2049 simple e-d-s Google contacts, each with one email address and no phone numbers etc. --- Now with comments as requested, and fixing a stupid bug caught by the tests.
(In reply to comment #4) > Now with comments as requested, and fixing a stupid bug caught by the tests. (and yes I've checked that it's still equally fast - the speed-up wasn't caused by that bug :-)
Review of attachment 238719 [details] [review]: Go for it.
Comment on attachment 238719 [details] [review] collection comparators: optimize the case of empty collections f2a0df2d22
Fixed in git for 0.9.2