1 |
Author: zmedico |
2 |
Date: 2008-04-14 16:32:19 +0000 (Mon, 14 Apr 2008) |
3 |
New Revision: 9890 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
When regenerating USE_EXPAND in config.setcpv(), improve performance by |
9 |
using regular expression instead of str.startswith(). |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/__init__.py 2008-04-14 01:35:25 UTC (rev 9889) |
15 |
+++ main/trunk/pym/portage/__init__.py 2008-04-14 16:32:19 UTC (rev 9890) |
16 |
@@ -2035,8 +2035,12 @@ |
17 |
for var in use_expand: |
18 |
prefix = var.lower() + "_" |
19 |
prefix_len = len(prefix) |
20 |
- expand_flags = set([ x[prefix_len:] for x in use \ |
21 |
- if x.startswith(prefix) ]) |
22 |
+ prefix_re = re.compile(r'^(%s)(.*)' % prefix) |
23 |
+ expand_flags = set() |
24 |
+ for x in use: |
25 |
+ m = prefix_re.match(x) |
26 |
+ if m is not None: |
27 |
+ expand_flags.add(m.group(2)) |
28 |
var_split = self.get(var, "").split() |
29 |
# Preserve the order of var_split because it can matter for things |
30 |
# like LINGUAS. |
31 |
@@ -2047,15 +2051,18 @@ |
32 |
var_split = [ x for x in var_split if x != "*" ] |
33 |
has_iuse = set() |
34 |
for x in iuse_implicit: |
35 |
- if x.startswith(prefix): |
36 |
- has_iuse.add(x[prefix_len:]) |
37 |
+ m = prefix_re.match(x) |
38 |
+ if m is not None: |
39 |
+ has_iuse.add(m.group(2)) |
40 |
if has_wildcard: |
41 |
# * means to enable everything in IUSE that's not masked |
42 |
if has_iuse: |
43 |
for x in iuse_implicit: |
44 |
- if x.startswith(prefix) and x not in self.usemask: |
45 |
- suffix = x[prefix_len:] |
46 |
- var_split.append(suffix) |
47 |
+ if x in self.usemask: |
48 |
+ continue |
49 |
+ m = prefix_re.match(x) |
50 |
+ if m is not None: |
51 |
+ var_split.append(m.group(2)) |
52 |
use.add(x) |
53 |
else: |
54 |
# If there is a wildcard and no matching flags in IUSE then |
55 |
|
56 |
-- |
57 |
gentoo-commits@l.g.o mailing list |