From 09741ecf33cfe7ba64ff79d788ecc6194800e190 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 12 Dec 2014 19:16:26 +0100 Subject: [PATCH] implement get_next_higher_bit using get_highest_on_bit to benefit from optimisations --- panda/src/putil/pbitops.I | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/panda/src/putil/pbitops.I b/panda/src/putil/pbitops.I index 452a04f638..5273eb8b13 100644 --- a/panda/src/putil/pbitops.I +++ b/panda/src/putil/pbitops.I @@ -267,8 +267,7 @@ get_highest_on_bit(PN_uint64 x) { //////////////////////////////////////////////////////////////////// INLINE int get_next_higher_bit(PN_uint16 x) { - PN_uint16 w = flood_bits_down(x); - return count_bits_in_word(w); + return get_highest_on_bit(x) + 1; } //////////////////////////////////////////////////////////////////// @@ -280,8 +279,7 @@ get_next_higher_bit(PN_uint16 x) { //////////////////////////////////////////////////////////////////// INLINE int get_next_higher_bit(PN_uint32 x) { - PN_uint32 w = flood_bits_down(x); - return count_bits_in_word(w); + return get_highest_on_bit(x) + 1; } //////////////////////////////////////////////////////////////////// @@ -293,6 +291,5 @@ get_next_higher_bit(PN_uint32 x) { //////////////////////////////////////////////////////////////////// INLINE int get_next_higher_bit(PN_uint64 x) { - PN_uint64 w = flood_bits_down(x); - return count_bits_in_word(w); + return get_highest_on_bit(x) + 1; }