Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r12008 - main/trunk/pym/portage/cache
Date: Thu, 20 Nov 2008 21:02:44
Message-Id: E1L3Gfh-0005Qq-Jj@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-11-20 21:02:40 +0000 (Thu, 20 Nov 2008)
3 New Revision: 12008
4
5 Modified:
6 main/trunk/pym/portage/cache/metadata.py
7 Log:
8 Inside _parse_data(), don't rely on the magic 22 line count for the flat_list
9 format, since it doesn't make a significant performance difference and it
10 places an artificial limit on the number of keys that can be stored.
11
12
13 Modified: main/trunk/pym/portage/cache/metadata.py
14 ===================================================================
15 --- main/trunk/pym/portage/cache/metadata.py 2008-11-20 02:40:33 UTC (rev 12007)
16 +++ main/trunk/pym/portage/cache/metadata.py 2008-11-20 21:02:40 UTC (rev 12008)
17 @@ -3,7 +3,7 @@
18 # License: GPL2
19 # $Id$
20
21 -import os, stat, types
22 +import os, re, stat, types
23 from portage.cache import flat_hash
24 import portage.eclass_cache
25 from portage.cache.template import reconstruct_eclasses
26 @@ -22,6 +22,8 @@
27
28 autocommits = True
29
30 + _hashed_re = re.compile('^(\\w+)=([^\n]*)')
31 +
32 def __init__(self, location, *args, **config):
33 loc = location
34 super(database, self).__init__(location, *args, **config)
35 @@ -33,35 +35,24 @@
36
37
38 def _parse_data(self, data, cpv):
39 - # easy attempt first.
40 + _hashed_re_match = self._hashed_re.match
41 data = list(data)
42 - if len(data) != magic_line_count:
43 - d = flat_hash.database._parse_data(self, data, cpv)
44 - else:
45 - # this one's interesting.
46 - d = {}
47 + d = {}
48
49 - for line in data:
50 - # yes, meant to iterate over a string.
51 - hashed = False
52 - # poor mans enumerate. replace when python 2.3 is required
53 - for idx, c in zip(range(len(line)), line):
54 - if not c.isalpha():
55 - if c == "=" and idx > 0:
56 - hashed = True
57 - d[line[:idx]] = line[idx + 1:].rstrip("\n")
58 - elif c == "_" or c.isdigit():
59 - continue
60 - break
61 + for line in data:
62 + hashed = False
63 + hashed_match = _hashed_re_match(line)
64 + if hashed_match is None:
65 + d.clear()
66 + try:
67 + for i, key in enumerate(self.auxdbkey_order):
68 + d[key] = data[i].rstrip("\n")
69 + except IndexError:
70 + pass
71 + break
72 + else:
73 + d[hashed_match.group(1)] = hashed_match.group(2)
74
75 - if not hashed:
76 - # non hashed.
77 - d.clear()
78 - # poor mans enumerate. replace when python 2.3 is required
79 - for idx, key in zip(range(len(self.auxdbkey_order)), self.auxdbkey_order):
80 - d[key] = data[idx].strip()
81 - break
82 -
83 if "_eclasses_" not in d:
84 if "INHERITED" in d:
85 d["_eclasses_"] = self.ec.get_eclass_data(d["INHERITED"].split(), from_master_only=True)