diff options
author | Simon Ser <contact@emersion.fr> | 2023-05-03 21:16:25 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-05-09 09:33:06 +0000 |
commit | 0e0ae7e290f28f4ee4ad807acb955d6b276d9e58 (patch) | |
tree | 41b78402bf7b96e90045bed8df0fbbaefc43c0d8 /src | |
parent | 11b17c1286afac0e6e399986df83721a4ea9487b (diff) | |
download | wayland-0e0ae7e290f28f4ee4ad807acb955d6b276d9e58.tar.gz |
util: simplify wl_fixed_to_double()
We can just use a simple division instead of bit operations with
magic numbers. Readability matters more than performance here.
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/296
Signed-off-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'src')
-rw-r--r-- | src/wayland-util.h | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/wayland-util.h b/src/wayland-util.h index b4cdcfa..272a3c0 100644 --- a/src/wayland-util.h +++ b/src/wayland-util.h @@ -613,14 +613,7 @@ typedef int32_t wl_fixed_t; static inline double wl_fixed_to_double(wl_fixed_t f) { - union { - double d; - int64_t i; - } u; - - u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f; - - return u.d - (3LL << 43); + return f / 256.0; } /** |