diff mbox

vnc: replace hweight_long() with ctpopl()

Message ID 1489415605-13105-1-git-send-email-clg@kaod.org
State New
Headers show

Commit Message

Cédric Le Goater March 13, 2017, 2:33 p.m. UTC
ctpopl() has a better implementation than hweight_long() and ui/vnc.c
being the last user of hweight_long(), we can simply remove it.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/qemu/bitops.h | 10 ----------
 ui/vnc.c              |  6 +++---
 2 files changed, 3 insertions(+), 13 deletions(-)

Comments

Peter Maydell March 13, 2017, 2:40 p.m. UTC | #1
On 13 March 2017 at 15:33, Cédric Le Goater <clg@kaod.org> wrote:
> ctpopl() has a better implementation than hweight_long() and ui/vnc.c
> being the last user of hweight_long(), we can simply remove it.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
diff mbox

Patch

diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 1881284cb5f3..3f0926cf40ca 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -201,16 +201,6 @@  static inline unsigned long find_first_zero_bit(const unsigned long *addr,
     return find_next_zero_bit(addr, size, 0);
 }
 
-static inline unsigned long hweight_long(unsigned long w)
-{
-    unsigned long count;
-
-    for (count = 0; w; w >>= 1) {
-        count += w & 1;
-    }
-    return count;
-}
-
 /**
  * rol8 - rotate an 8-bit value left
  * @word: value to rotate
diff --git a/ui/vnc.c b/ui/vnc.c
index 51f4b309596e..8a2789a8c26b 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2154,15 +2154,15 @@  static void set_pixel_format(VncState *vs, int bits_per_pixel,
     }
 
     vs->client_pf.rmax = red_max ? red_max : 0xFF;
-    vs->client_pf.rbits = hweight_long(red_max);
+    vs->client_pf.rbits = ctpopl(red_max);
     vs->client_pf.rshift = red_shift;
     vs->client_pf.rmask = red_max << red_shift;
     vs->client_pf.gmax = green_max ? green_max : 0xFF;
-    vs->client_pf.gbits = hweight_long(green_max);
+    vs->client_pf.gbits = ctpopl(green_max);
     vs->client_pf.gshift = green_shift;
     vs->client_pf.gmask = green_max << green_shift;
     vs->client_pf.bmax = blue_max ? blue_max : 0xFF;
-    vs->client_pf.bbits = hweight_long(blue_max);
+    vs->client_pf.bbits = ctpopl(blue_max);
     vs->client_pf.bshift = blue_shift;
     vs->client_pf.bmask = blue_max << blue_shift;
     vs->client_pf.bits_per_pixel = bits_per_pixel;