~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/registry.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        self._obj = obj
70
70
        self._imported = True
71
71
 
72
 
    def __repr__(self):
73
 
        return "<%s.%s object at %x, module=%r attribute=%r>" % (
74
 
            self.__class__.__module__, self.__class__.__name__, id(self),
75
 
            self._module_name, self._member_name)
76
 
 
77
72
 
78
73
class Registry(object):
79
74
    """A class that registers objects to a name.
167
162
        """
168
163
        return self._dict[self._get_key_or_default(key)].get_obj()
169
164
 
170
 
    def get_prefix(self, fullname):
171
 
        """Return an object whose key is a prefix of the supplied value.
172
 
 
173
 
        :fullname: The name to find a prefix for
174
 
        :return: a tuple of (object, remainder), where the remainder is the
175
 
            portion of the name that did not match the key.
176
 
        """
177
 
        for key, value in self.iteritems():
178
 
            if fullname.startswith(key):
179
 
                return value, fullname[len(key):]
180
 
 
181
165
    def _get_key_or_default(self, key=None):
182
166
        """Return either 'key' or the default key if key is None"""
183
167
        if key is not None: