Author: Alex Gaynor <[email protected]>
Branch: 
Changeset: r53241:dd12179efc3c
Date: 2012-03-05 19:02 -0500
http://bitbucket.org/pypy/pypy/changeset/dd12179efc3c/

Log:    reorganize rstruct a bit, to be friendlier to the JIT

diff --git a/pypy/rlib/rstruct/nativefmttable.py 
b/pypy/rlib/rstruct/nativefmttable.py
--- a/pypy/rlib/rstruct/nativefmttable.py
+++ b/pypy/rlib/rstruct/nativefmttable.py
@@ -27,10 +27,13 @@
 float_buf = lltype.malloc(rffi.FLOATP.TO, 1, flavor='raw', immortal=True)
 
 @jit.dont_look_inside
+def double_to_ccharp(doubleval):
+    double_buf[0] = doubleval
+    return rffi.cast(rffi.CCHARP, double_buf)
+
 def pack_double(fmtiter):
     doubleval = fmtiter.accept_float_arg()
-    double_buf[0] = doubleval
-    p = rffi.cast(rffi.CCHARP, double_buf)
+    p = double_to_ccharp(doubleval)
     fmtiter.result.append_charpsize(p, rffi.sizeof(rffi.DOUBLE))
 
 @specialize.argtype(0)
@@ -43,11 +46,14 @@
     fmtiter.appendobj(doubleval)
 
 @jit.dont_look_inside
+def float_to_ccharp(floatval):
+    float_buf[0] = floatval
+    return rffi.cast(rffi.CCHARP, float_buf)
+
 def pack_float(fmtiter):
     doubleval = fmtiter.accept_float_arg()
     floatval = r_singlefloat(doubleval)
-    float_buf[0] = floatval
-    p = rffi.cast(rffi.CCHARP, float_buf)
+    p = float_to_ccharp(floatval)
     fmtiter.result.append_charpsize(p, rffi.sizeof(rffi.FLOAT))
 
 @specialize.argtype(0)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to