[pypy-commit] pypy default: cleanup byteswap function
bdkearns
noreply at buildbot.pypy.org
Fri Feb 15 12:00:08 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r61253:7567d8e56a54
Date: 2013-02-15 05:01 -0500
http://bitbucket.org/pypy/pypy/changeset/7567d8e56a54/
Log: cleanup byteswap function
diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -630,21 +630,16 @@
uint2singlefloat, singlefloat2uint
T = lltype.typeOf(arg)
- is_float = False
- is_single_float = False
if T == lltype.SingleFloat:
- T = rffi.UINT
- is_single_float = True
arg = singlefloat2uint(arg)
elif T == lltype.Float:
- is_float = True
- T = rffi.LONGLONG
arg = float2longlong(arg)
elif T == lltype.LongFloat:
assert False
else:
# we cannot do arithmetics on small ints
arg = widen(arg)
+
if rffi.sizeof(T) == 1:
res = arg
elif rffi.sizeof(T) == 2:
@@ -667,9 +662,9 @@
(f >> 24) | (g >> 40) | (h >> 56))
else:
assert False # unreachable code
- if is_single_float:
+
+ if T == lltype.SingleFloat:
return uint2singlefloat(rffi.cast(rffi.UINT, res))
- if is_float:
- res = rffi.cast(rffi.LONGLONG, res)
- return longlong2float(res)
+ if T == lltype.Float:
+ return longlong2float(rffi.cast(rffi.LONGLONG, res))
return rffi.cast(T, res)
More information about the pypy-commit
mailing list