Rev 3081: Using just PyObject_Compare: 3.6s-3.9s in http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/patience_tuples

John Arbash Meinel john at arbash-meinel.com
Wed Dec 5 14:10:32 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/patience_tuples

------------------------------------------------------------
revno: 3081
revision-id:john at arbash-meinel.com-20071205140908-d02s0wgd2wssygwv
parent: john at arbash-meinel.com-20071205140005-aexhlajexv5r1w3l
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: patience_tuples
timestamp: Wed 2007-12-05 08:09:08 -0600
message:
  Using just PyObject_Compare: 3.6s-3.9s
modified:
  bzrlib/_patiencediff_c.c       _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
-------------- next part --------------
=== modified file 'bzrlib/_patiencediff_c.c'
--- a/bzrlib/_patiencediff_c.c	2007-12-05 14:00:05 +0000
+++ b/bzrlib/_patiencediff_c.c	2007-12-05 14:09:08 +0000
@@ -75,7 +75,6 @@
     Py_ssize_t equiv;  /* equivalence class */
     Py_ssize_t len;
     const PyObject *data;
-    const char *c_data;
 };
 
 
@@ -152,14 +151,8 @@
 static inline int
 compare_lines(struct line *a, struct line *b)
 {
-    if (((a->hash != b->hash) || (a->len != b->len))) {
-        return 0;
-    }
-    if (a->c_data != NULL && b->c_data != NULL) {
-        return memcmp(a->c_data, b->c_data, a->len);
-    } else {
-        return PyObject_Compare((PyObject *)a->data, (PyObject *)b->data);
-    }
+    return ((a->hash != b->hash) || (a->len != b->len)
+            || PyObject_Compare((PyObject *)a->data, (PyObject *)b->data));
 }
 
 
@@ -577,7 +570,6 @@
     for (i = 0; i < size; i++) {
         item = PySequence_Fast_GET_ITEM(seq, i);
         line->data = item;
-        line->c_data = NULL;
         if (PyString_Check(item)) {
             long hash;
             const char *p;
@@ -586,7 +578,7 @@
                and doesn't give particularly better results
              */
             line->len = PyString_GET_SIZE(item);
-            line->c_data = p = PyString_AS_STRING(item);
+            p = PyString_AS_STRING(item);
             /* 'djb2' hash. This gives us a nice compromise between fast hash
                 function and a hash with less collisions. The algorithm doesn't
                 use the hash for actual lookups, only for building the table



More information about the bazaar-commits mailing list