summaryrefslogtreecommitdiffstats
path: root/hacks/munch.c
diff options
context:
space:
mode:
authorSimon Rettberg2021-04-06 14:43:39 +0200
committerSimon Rettberg2021-04-07 13:38:37 +0200
commit38886de0c3e9ea5729ef23e4c653fa2822f52e8f (patch)
tree9b799c8c968a92cc77746a95e0e8bdd90b6b13c3 /hacks/munch.c
parentMaybe not remove, but ... (diff)
downloadxscreensaver-openslx.tar.gz
xscreensaver-openslx.tar.xz
xscreensaver-openslx.zip
xscreensaver 6.00v28r1openslx
Diffstat (limited to 'hacks/munch.c')
-rw-r--r--hacks/munch.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/hacks/munch.c b/hacks/munch.c
index c45e37f..f24629f 100644
--- a/hacks/munch.c
+++ b/hacks/munch.c
@@ -64,6 +64,7 @@
*/
#include <math.h>
+#include "pow2.h"
#include "screenhack.h"
typedef struct _muncher {
@@ -97,20 +98,6 @@ struct state {
};
-/*
- * dumb way to get # of digits in number. Probably faster than actually
- * doing a log and a division, maybe.
- */
-static int dumb_log_2(int k)
-{
- int r = -1;
- while (k > 0) {
- k >>= 1; r++;
- }
- return r;
-}
-
-
static void calc_logwidths (struct state *st)
{
/* Choose a range of square sizes based on the window size. We want
@@ -121,9 +108,9 @@ static void calc_logwidths (struct state *st)
if (st->window_height < st->window_width &&
st->window_width < st->window_height * 5) {
- st->logmaxwidth = (int)dumb_log_2(st->window_height * 0.8);
+ st->logmaxwidth = (int)i_log2(st->window_height * 0.8);
} else {
- st->logmaxwidth = (int)dumb_log_2(st->window_width * 0.8);
+ st->logmaxwidth = (int)i_log2(st->window_width * 0.8);
}
if (st->logmaxwidth < 2) {