From 34c9962e4dc31acfc96690ee66a5e2ef19b670c3 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 10 Dec 2018 12:33:11 +0100 Subject: [PATCH] remove Popcount_word() --- src/misc.c | 24 +----------------------- src/misc.h | 5 +---- src/oldies.c | 4 ++-- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/misc.c b/src/misc.c index 37159b4d..768e4b54 100644 --- a/src/misc.c +++ b/src/misc.c @@ -839,31 +839,9 @@ double Fround(double n, unsigned d) return floor(n * exp + 0.5) / exp; } -/// Count number of bits in a word (16bit). -/// Based on Wikipedia article for Hamming_weight, it's optimized -/// for cases when zeroes are more frequent. -int Popcount_word(word x) -{ - word count; - for (count=0; x; count++) - x &= x-1; - return count; -} - -/// Count number of bits in a dword (32bit). -/// Based on Wikipedia article for Hamming_weight, it's optimized -/// for cases when zeroes are more frequent. -int Popcount_dword(dword x) -{ - dword count; - for (count=0; x; count++) - x &= x-1; - return count; -} - // Fonction retournant le libellé d'une mode (ex: " 320x200") -char * Mode_label(int mode) +const char * Mode_label(int mode) { static char str[24]; if (! Video_mode[mode].Fullscreen) diff --git a/src/misc.h b/src/misc.h index 5b1512ce..ccc081c1 100644 --- a/src/misc.h +++ b/src/misc.h @@ -151,12 +151,9 @@ double Fround(double n, unsigned d); int Min(int a,int b); int Max(int a,int b); -char* Mode_label(int mode); +const char* Mode_label(int mode); int Convert_videomode_arg(const char *argument); -int Popcount_word(word x); -int Popcount_dword(dword x); - /// Return a number of milliseconds dword GFX2_GetTicks(void); diff --git a/src/oldies.c b/src/oldies.c index a9d6b5f2..25021278 100644 --- a/src/oldies.c +++ b/src/oldies.c @@ -168,7 +168,7 @@ int C64_FLI(T_IO_Context * context, byte *bitmap, byte *screen_ram, byte *color_ memset(usage,0,16*sizeof(dword)); for (col=0;col<40;col++) { - used_colors_count[row][col]=Popcount_word(used_colors[row][col]); + used_colors_count[row][col] = count_set_bits(used_colors[row][col]); // Count which colors are used 3 times if (used_colors_count[row][col]==3) { @@ -239,7 +239,7 @@ int C64_FLI(T_IO_Context * context, byte *bitmap, byte *screen_ram, byte *color_ } } } - if (filter != 0 && Popcount_word(filter) == 1) + if (filter != 0 && count_set_bits(filter) == 1) { // Only one color matched all needs: Use it. i=1;