Rev 4528: Some small tweaks, add more documentation for 'add_special_text'. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate

John Arbash Meinel john at arbash-meinel.com
Wed Jul 8 16:28:09 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate

------------------------------------------------------------
revno: 4528
revision-id: john at arbash-meinel.com-20090708152805-nbgmogmzfbfbuu28
parent: john at arbash-meinel.com-20090708152014-7effsnpiore2yyy4
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Wed 2009-07-08 10:28:05 -0500
message:
  Some small tweaks, add more documentation for 'add_special_text'.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_py.py'
--- a/bzrlib/_annotator_py.py	2009-07-08 15:20:14 +0000
+++ b/bzrlib/_annotator_py.py	2009-07-08 15:28:05 +0000
@@ -224,7 +224,16 @@
         self._record_annotation(key, parent_keys, annotations)
 
     def add_special_text(self, key, parent_keys, text):
-        """Add a specific text to the graph."""
+        """Add a specific text to the graph.
+
+        This is used to add a text which is not otherwise present in the
+        versioned file. (eg. a WorkingTree injecting 'current:' into the
+        graph to annotate the edited content.)
+
+        :param key: The key to use to request this text be annotated
+        :param parent_keys: The parents of this text
+        :param text: A string containing the content of the text
+        """
         self._parent_map[key] = parent_keys
         self._text_cache[key] = osutils.split_lines(text)
         self._heads_provider = None

=== modified file 'bzrlib/_annotator_pyx.pyx'
--- a/bzrlib/_annotator_pyx.pyx	2009-07-08 15:20:14 +0000
+++ b/bzrlib/_annotator_pyx.pyx	2009-07-08 15:28:05 +0000
@@ -117,7 +117,11 @@
     new_ann = PyTuple_New(PyTuple_GET_SIZE(ann_one)
                           + PyTuple_GET_SIZE(ann_two))
     while left != NULL and right != NULL:
-        if (PyObject_RichCompareBool_ptr(left, right, Py_EQ)):
+        # left == right is done by PyObject_RichCompareBool_ptr, however it
+        # avoids a function call for a very common case. Drops 'time bzr
+        # annotate NEWS' from 7.25s to 7.16s, so it *is* a visible impact.
+        if (left == right
+            or PyObject_RichCompareBool_ptr(left, right, Py_EQ)):
             # Identical values, step both
             Py_INCREF_ptr(left)
             PyTuple_SET_ITEM_ptr(new_ann, out_pos, left)



More information about the bazaar-commits mailing list