Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct-2
Changeset: r91281:38cd23755b61
Date: 2017-05-13 15:01 +0200
http://bitbucket.org/pypy/pypy/changeset/38cd23755b61/

Log:    use the fast path also for the native float/double packing

diff --git a/rpython/rlib/rstruct/nativefmttable.py 
b/rpython/rlib/rstruct/nativefmttable.py
--- a/rpython/rlib/rstruct/nativefmttable.py
+++ b/rpython/rlib/rstruct/nativefmttable.py
@@ -29,6 +29,9 @@
 
 def pack_double(fmtiter):
     doubleval = fmtiter.accept_float_arg()
+    if std.pack_fastpath(rffi.DOUBLE)(fmtiter, doubleval):
+        return
+    # slow path
     value = longlong2float.float2longlong(doubleval)
     pack_float_to_buffer(fmtiter.result, fmtiter.pos, value, 8, 
fmtiter.bigendian)
     fmtiter.advance(8)
@@ -36,6 +39,9 @@
 def pack_float(fmtiter):
     doubleval = fmtiter.accept_float_arg()
     floatval = r_singlefloat(doubleval)
+    if std.pack_fastpath(rffi.FLOAT)(fmtiter, floatval):
+        return
+    # slow path
     value = longlong2float.singlefloat2uint(floatval)
     value = widen(value)
     pack_float_to_buffer(fmtiter.result, fmtiter.pos, value, 4, 
fmtiter.bigendian)
diff --git a/rpython/rlib/rstruct/test/test_pack.py 
b/rpython/rlib/rstruct/test/test_pack.py
--- a/rpython/rlib/rstruct/test/test_pack.py
+++ b/rpython/rlib/rstruct/test/test_pack.py
@@ -144,3 +144,9 @@
     bigendian = nativefmttable.native_is_bigendian
     fmt_prefix = '@'
     fmttable = nativefmttable.native_fmttable
+
+class TestNativeSlowPath(BaseTestPack):
+    USE_FASTPATH = False
+    bigendian = nativefmttable.native_is_bigendian
+    fmt_prefix = '@'
+    fmttable = nativefmttable.native_fmttable
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to