1 |
Author: zmedico |
2 |
Date: 2008-06-20 16:47:45 +0000 (Fri, 20 Jun 2008) |
3 |
New Revision: 10742 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dep.py |
7 |
Log: |
8 |
Make the Atom cache dict private and add a docstring for _AtomCache. |
9 |
|
10 |
|
11 |
Modified: main/trunk/pym/portage/dep.py |
12 |
=================================================================== |
13 |
--- main/trunk/pym/portage/dep.py 2008-06-20 16:18:46 UTC (rev 10741) |
14 |
+++ main/trunk/pym/portage/dep.py 2008-06-20 16:47:45 UTC (rev 10742) |
15 |
@@ -393,12 +393,15 @@ |
16 |
return _use_dep(tokens) |
17 |
|
18 |
class _AtomCache(type): |
19 |
- atoms = {} |
20 |
+ """ |
21 |
+ Cache Atom instances from constructor calls and reuse |
22 |
+ identical instances when available. |
23 |
+ """ |
24 |
def __call__(cls, s): |
25 |
- instance = cls.atoms.get(s) |
26 |
+ instance = cls._atoms.get(s) |
27 |
if instance is None: |
28 |
instance = super(_AtomCache, cls).__call__(s) |
29 |
- cls.atoms[s] = instance |
30 |
+ cls._atoms[s] = instance |
31 |
return instance |
32 |
|
33 |
class Atom(object): |
34 |
@@ -409,6 +412,7 @@ |
35 |
""" |
36 |
|
37 |
__metaclass__ = _AtomCache |
38 |
+ _atoms = {} |
39 |
|
40 |
_str_methods = ("endswith", "find", "index", "lstrip", "replace", |
41 |
"startswith", "strip", "rindex", "rfind", "rstrip", "__getitem__", |
42 |
|
43 |
-- |
44 |
gentoo-commits@l.g.o mailing list |