summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-12 12:34:25 -0300
committerWerner Almesberger <werner@almesberger.net>2014-09-12 12:34:25 -0300
commit147d9e79b009a86e03ec15c8ba5e34961ffa9cb5 (patch)
treece0358b273dd952a8426936c453974eb2d31de0d /meme
parent13c605449235253d363e0dc1653e7a09f6c700be (diff)
downloadmisc-147d9e79b009a86e03ec15c8ba5e34961ffa9cb5.tar.gz
misc-147d9e79b009a86e03ec15c8ba5e34961ffa9cb5.tar.bz2
misc-147d9e79b009a86e03ec15c8ba5e34961ffa9cb5.zip
meme/gui.c (proximity_fn): use single-precision math
before: min/avg/max = 17/25/39 ms after: min/avg/max = 14/19/29 ms
Diffstat (limited to 'meme')
-rw-r--r--meme/gui.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 7d02ad4..3ed56d9 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -268,7 +268,7 @@ static void show_cursor(SDL_Surface *s, const struct vertex *v)
struct proximity {
int x, y;
const struct vertex *best;
- double best_d;
+ float best_d;
};
@@ -276,7 +276,7 @@ struct proximity {
static bool proximity_fn(const struct vertex *v, void *user)
{
struct proximity *p = user;
- double d = hypot(v->x - p->x, v->y - p->y);
+ float d = hypotf(v->x - p->x, v->y - p->y);
if (!p->best || d < p->best_d) {
p->best_d = d;
@@ -291,13 +291,13 @@ static bool proximity_fn(const struct vertex *v, void *user)
static bool proximity_fn(const struct vertex *v, void *user)
{
struct proximity *p = user;
- double d;
+ float d;
if (p->best &&
(abs(v->x - p->x) >= p->best_d || abs(v->y - p->y) >= p->best_d))
return 0;
- d = hypot(v->x - p->x, v->y - p->y);
+ d = hypotf(v->x - p->x, v->y - p->y);
if (p->best && d >= p->best_d)
return 0;