Make ExtendedAtomDict.__getitem__() return the value directly from
authorZac Medico <zmedico@gentoo.org>
Tue, 3 Aug 2010 08:40:04 +0000 (01:40 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 3 Aug 2010 08:40:04 +0000 (01:40 -0700)
self._extended when given a wildcard (rather than make an unnecessary
copy).

pym/portage/dep/__init__.py

index 12e32c36d8bddc460bf188046f638e50c2324351..0ba96bdec9b70a698fef886774d40e815ccdab61 100644 (file)
@@ -796,6 +796,9 @@ class ExtendedAtomDict(portage.cache.mappings.MutableMapping):
                if not isinstance(cp, basestring):
                        raise KeyError(cp)
 
+               if '*' in cp:
+                       return self._extended[cp]
+
                ret = self._value_class()
                normal_match = self._normal.get(cp)
                match = False
@@ -809,26 +812,15 @@ class ExtendedAtomDict(portage.cache.mappings.MutableMapping):
                        else:
                                raise NotImplementedError()
 
-               if '*' in cp:
-                       v = self._extended.get(cp)
-                       if v is not None:
+               for extended_cp in self._extended:
+                       if extended_cp_match(extended_cp, cp):
                                match = True
                                if hasattr(ret, "update"):
-                                       ret.update(v)
+                                       ret.update(self._extended[extended_cp])
                                elif hasattr(ret, "extend"):
-                                       ret.extend(v)
+                                       ret.extend(self._extended[extended_cp])
                                else:
                                        raise NotImplementedError()
-               else:
-                       for extended_cp in self._extended:
-                               if extended_cp_match(extended_cp, cp):
-                                       match = True
-                                       if hasattr(ret, "update"):
-                                               ret.update(self._extended[extended_cp])
-                                       elif hasattr(ret, "extend"):
-                                               ret.extend(self._extended[extended_cp])
-                                       else:
-                                               raise NotImplementedError()
 
                if not match:
                        raise KeyError(cp)