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 |