Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] repoman: filter out duplicate dependencies in error messages
Date: Tue, 05 Jan 2016 05:36:21
Message-Id: 568B5640.7040102@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] repoman: filter out duplicate dependencies in error messages by Mike Frysinger
1 On 01/04/2016 01:30 PM, Mike Frysinger wrote:
2 > + # Filter out duplicates. We do this by hand (rather
3 > + # than use a set) so the order is stable and better
4 > + # matches the order that's in the ebuild itself.
5 > + atoms = []
6 > + for atom in all_atoms:
7 > + if atom not in atoms:
8 > + atoms.append(atom)
9 > +
10
11 Alternative implementation using OrderedDict which has O(1) average
12 complexity for containment checks, rather than O(N):
13
14 atoms = OrderedDict()
15 for atom in all_atoms:
16 atoms.setdefault(atom, atom)
17 atoms = list(atoms)
18
19 --
20 Thanks,
21 Zac