Gentoo Archives: gentoo-commits

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