Git
Wiki
Site
projects
/
soft
/
lpc122x
/
core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
82824e4
)
Fix bits_set
author
Nathael Pajani
<nathael.pajani@ed3l.fr>
Thu, 19 Nov 2020 18:48:20 +0000
(19:48 +0100)
committer
Nathael Pajani
<nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:05 +0000
(17:03 +0100)
lib/utils.c
patch
|
blob
|
history
diff --git
a/lib/utils.c
b/lib/utils.c
index
96ad730
..
96ab676
100644
(file)
--- a/
lib/utils.c
+++ b/
lib/utils.c
@@
-93,14
+93,10
@@
uint8_t bits_set(uint32_t x)
static const uint8_t bval_bsets[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
uint8_t r = 0; /* Accumulator for the total bits set in x */
- r = bval_bsets[x & 0xFF];
- x >>= 8;
- r += bval_bsets[x & 0xFF];
- x >>= 8;
- r += bval_bsets[x & 0xFF];
- x >>= 8;
- r += bval_bsets[x & 0xFF];
-
+ while (x) {
+ r += bval_bsets[x & 0x0F];
+ x >>= 4;
+ }
return r;
}
Techno-Innov
42 impasse de la Combe du Bois
01150 Blyes - France
contact@techno-innov.fr
Design et hébergement du site :
Techno-Innov
Techno-Innov
- SARL Coopérative
539 169 417 RCS Bourg-en-Bresse
Ce site n'utilise pas de cookies, désolé pour les gourmands !