Rev 3080: The numbers are a bit noisy... 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:01:29 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/patience_tuples
------------------------------------------------------------
revno: 3080
revision-id:john at arbash-meinel.com-20071205140005-aexhlajexv5r1w3l
parent: john at arbash-meinel.com-20071205134925-4s1wo9k920cbnavb
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: patience_tuples
timestamp: Wed 2007-12-05 08:00:05 -0600
message:
The numbers are a bit noisy...
Using djb2 hash and memcmp/PyObject_Compare ranges from: 3.5s-4.1s
Using original code ranges from: 3.9s-4.1s
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 13:49:25 +0000
+++ b/bzrlib/_patiencediff_c.c 2007-12-05 14:00:05 +0000
@@ -587,15 +587,16 @@
*/
line->len = PyString_GET_SIZE(item);
line->c_data = 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
- // so a better hash function wouldn't bring us much benefit, but
- // would make this loading code slower. */
- // hash = 5381;
- // for (j = 0; j < line->len; j++)
- // hash = ((hash << 5) + hash) + *p++;
- line->hash = PyObject_Hash(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
+ so a better hash function wouldn't bring us much benefit, but
+ would make this loading code slower. */
+ hash = 5381;
+ for (j = 0; j < line->len; j++)
+ hash = ((hash << 5) + hash) + *p++;
+ line->hash = hash;
+ // line->hash = PyObject_Hash(item);
} else if (PyTuple_Check(item)) {
total_len = 0;
tuple_len = PyObject_Length(item);
More information about the bazaar-commits
mailing list