[pypy-svn] r76934 - pypy/trunk/pypy/rlib

arigo at codespeak.net arigo at codespeak.net
Wed Sep 8 10:42:10 CEST 2010


Author: arigo
Date: Wed Sep  8 10:42:07 2010
New Revision: 76934

Modified:
   pypy/trunk/pypy/rlib/rzipfile.py
Log:
Move the constant 0xffffffff out of the RPython functions.


Modified: pypy/trunk/pypy/rlib/rzipfile.py
==============================================================================
--- pypy/trunk/pypy/rlib/rzipfile.py	(original)
+++ pypy/trunk/pypy/rlib/rzipfile.py	Wed Sep  8 10:42:07 2010
@@ -16,15 +16,16 @@
 crc_32_tab = import_from_lib_pypy('binascii').crc_32_tab
 
 rcrc_32_tab = [r_uint(i) for i in crc_32_tab]
+mask32 = r_uint(0xffffffffL)
 
 def crc32(s, crc=0):
     result = 0
-    crc = ~r_uint(crc) & 0xffffffffL
+    crc = ~r_uint(crc) & mask32
     for c in s:
-        crc = rcrc_32_tab[(crc ^ r_uint(ord(c))) & 0xffL] ^ (crc >> 8)
+        crc = rcrc_32_tab[(crc ^ r_uint(ord(c))) & 0xff] ^ (crc >> 8)
         #/* Note:  (crc >> 8) MUST zero fill on left
 
-        result = crc ^ 0xffffffffL
+        result = crc ^ mask32
     
     return result
 
@@ -194,7 +195,7 @@
             (x.create_version, x.create_system, x.extract_version, x.reserved,
                 x.flag_bits, x.compress_type, t, d,
                 crc, x.compress_size, x.file_size) = centdir[1:12]
-            x.CRC = r_uint(crc) & 0xffffffff
+            x.CRC = r_uint(crc) & mask32
             x.dostime = t
             x.dosdate = d
             x.volume, x.internal_attr, x.external_attr = centdir[15:18]



More information about the Pypy-commit mailing list