[sugar] [PATCH] Avoid duplicates in the bundle registry
Tomeu Vizoso
tomeu at tomeuvizoso.net
Tue Jun 10 06:05:52 EDT 2008
(sorry about the late reply)
On Wed, May 28, 2008 at 1:15 PM, Michael Stone <michael at laptop.org> wrote:
> On Wed, May 28, 2008 at 10:46:45AM +0200, Tomeu Vizoso wrote:
>> On Tue, May 27, 2008 at 6:44 PM, Michael Stone <michael at laptop.org> wrote:
>> > On Tue, May 27, 2008 at 09:15:39AM +0200, Tomeu Vizoso wrote:
>> >> + for bundle in self._bundles:
>> >> + if new_bundle.get_bundle_id() == bundle.get_bundle_id():
>> >
>> > Why are we performing repeated linear search instead of storing bundles
>> > in a datastructure with sub-linear containment lookups (e.g. a set or a
>> > hashtable)?
>>
>> Because the patch is simpler this way. Why do you think that using a
>> set or a table might be better here?
>
> Because my algorithm (store a dict mapping bundle id to biggest version
> yet seen) makes the same decisions yours does with one hash table lookup
> instead of O(n) string comparisons?
We use dictionaries all around sugar, you can be sure we know what a
hash table is. Should we replace all the structures used in Sugar that
could be made more efficient?
I proposed the patch that was simplest while addressed the users
needs. I think that we should only do invasive changes where there's
something tangible to win.
Anyway, I guess we'll have to wait until some real testing is done for
8.2 in order to reach an agreement on what we should do with bundle
management.
Regards,
Tomeu
More information about the Sugar
mailing list