~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_known_graph_pyx.pyx

  • Committer: John Arbash Meinel
  • Date: 2009-08-17 17:23:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4629.
  • Revision ID: john@arbash-meinel.com-20090817172306-2w72juabo9wkj1vc
small cleanup, a bit of comment tweaking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    cdef object extra
64
64
 
65
65
    def __init__(self, key):
66
 
        cdef int i
67
 
 
68
66
        self.key = key
69
67
        self.parents = None
70
68
 
192
190
            parent_keys = <object>temp_parent_keys
193
191
            num_parent_keys = len(parent_keys)
194
192
            node = self._get_or_create_node(key)
195
 
            # We know how many parents, so we could pre allocate an exact sized
196
 
            # tuple here
 
193
            # We know how many parents, so we pre allocate the tuple
197
194
            parent_nodes = PyTuple_New(num_parent_keys)
198
 
            # We use iter here, because parent_keys maybe be a list or tuple
199
195
            for pos2 from 0 <= pos2 < num_parent_keys:
 
196
                # Note: it costs us 10ms out of 40ms to lookup all of these
 
197
                #       parents, it doesn't seem to be an allocation overhead,
 
198
                #       but rather a lookup overhead. There doesn't seem to be
 
199
                #       a way around it, and that is one reason why
 
200
                #       KnownGraphNode maintains a direct pointer to the parent
 
201
                #       node.
 
202
                # We use [] because parent_keys may be a tuple or list
200
203
                parent_node = self._get_or_create_node(parent_keys[pos2])
201
204
                # PyTuple_SET_ITEM will steal a reference, so INCREF first
202
205
                Py_INCREF(parent_node)