Rev 5167: Simplify further, if this isn't going to be hot enough to matter, make the in http://bazaar.launchpad.net/~jameinel/bzr/other/gz-double-zlib

John Arbash Meinel john at arbash-meinel.com
Thu Apr 29 18:19:30 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/other/gz-double-zlib

------------------------------------------------------------
revno: 5167
revision-id: john at arbash-meinel.com-20100429171926-jiekibi2mfp9ku8b
parent: gzlist at googlemail.com-20100419210431-jvis645p9vdpzuy1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: gz-double-zlib
timestamp: Thu 2010-04-29 12:19:26 -0500
message:
  Simplify further, if this isn't going to be hot enough to matter, make the
  code clean.
-------------- next part --------------
=== modified file 'bzrlib/_chk_map_pyx.pyx'
--- a/bzrlib/_chk_map_pyx.pyx	2010-04-19 21:04:31 +0000
+++ b/bzrlib/_chk_map_pyx.pyx	2010-04-29 17:19:26 +0000
@@ -36,7 +36,7 @@
     int PyString_CheckExact(object)
     char *PyString_AS_STRING(object s)
     Py_ssize_t PyString_GET_SIZE(object)
-    unsigned long PyInt_AsUnsignedLongMask(object)
+    unsigned long PyInt_AsUnsignedLongMask(object) except? -1
 
     int PyDict_SetItem(object d, object k, object v) except -1
 
@@ -101,7 +101,6 @@
     cdef unsigned long crc_val
     cdef Py_ssize_t out_off
     cdef char *c_out
-    cdef PyObject *bit
 
     if not StaticTuple_CheckExact(key):
         raise TypeError('key %r is not a StaticTuple' % (key,))
@@ -117,10 +116,7 @@
         # We use the _ptr variant, because GET_ITEM returns a borrowed
         # reference, and Pyrex assumes that returned 'object' are a new
         # reference
-        bit = StaticTuple_GET_ITEM_ptr(key, i)
-        if not PyString_CheckExact_ptr(bit):
-            raise TypeError('Bit %d of %r is not a string' % (i, key))
-        crc_val = PyInt_AsUnsignedLongMask(crc32(<object>bit))
+        crc_val = PyInt_AsUnsignedLongMask(crc32(key[i]))
         # Hex(val) order
         sprintf(c_out, '%08X', crc_val)
         c_out = c_out + 8
@@ -135,7 +131,6 @@
     cdef unsigned long crc_val
     cdef Py_ssize_t out_off
     cdef char *c_out
-    cdef PyObject *bit
 
     if not StaticTuple_CheckExact(key):
         raise TypeError('key %r is not a StaticTuple' % (key,))
@@ -148,11 +143,7 @@
         if i > 0:
             c_out[0] = c'\x00'
             c_out = c_out + 1
-        bit = StaticTuple_GET_ITEM_ptr(key, i)
-        if not PyString_CheckExact_ptr(bit):
-            raise TypeError('Bit %d of %r is not a string: %r'
-                            % (i, key, <object>bit))
-        crc_val = PyInt_AsUnsignedLongMask(crc32(<object>bit))
+        crc_val = PyInt_AsUnsignedLongMask(crc32(key[i]))
         # MSB order
         c_out[0] = (crc_val >> 24) & 0xFF
         c_out[1] = (crc_val >> 16) & 0xFF



More information about the bazaar-commits mailing list