hpfs: Use hweight32
PATCH 1/1 hpfs: Use hweight32
Use hweight32 instead of counting for each bit
Signed-off-by Akinobu Mita <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Al Viro <[email protected]>
--- fs/hpfs/super.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
fs/hpfs/super.c +2 -5
@@ -119,11 +119,8 @@ unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)unsigned i, count;if (!(bits =hpfs_map_4sectors (s, secno, &qbh,4 )))return 0 ; count =0 ; -for (i =0 ; i <2048 /sizeof (unsigned ); i++) { -unsigned b; -if (!bits[i])continue ; -for (b = bits[i]; b; b>>=1 ) count += b &1 ; - } +for (i =0 ; i <2048 /sizeof (unsigned ); i++) + count +=hweight32 (bits[i]);hpfs_brelse4 (&qbh);return count; }
Signature · 1 line
1.6.5.1
Quoted 16 lines · On Fri, 13 Nov 2009 16:07:08 +0900 Akinobu Mita <[email protected]> wrote:
Use hweight32 instead of counting for each bit
Signed-off-by Akinobu Mita <[email protected]>Cc Mikulas Patocka <[email protected]>Cc Al Viro <[email protected]>--- fs/hpfs/super.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)fs/hpfs/super.c +0
-0@@ -119,11 +119,8 @@ unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)unsigned i, count;if (!(bits =hpfs_map_4sectors (s, secno, &qbh,4 )))return 0 ;
fs/hpfs/super.c unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) · line 125
Quoted 10 lines
fs/hpfs/super.c +2
-5count =0 ; -for (i =0 ; i <2048 /sizeof (unsigned ); i++) { -unsigned b; -if (!bits[i])continue ; -for (b = bits[i]; b; b>>=1 ) count += b &1 ; - } +for (i =0 ; i <2048 /sizeof (unsigned ); i++) + count +=hweight32 (bits[i]);hpfs_brelse4 (&qbh);return count;
Could actualy use bitmap_weight() here.
It's a bit naughty, because bitmap_weight() operates on long*'s, but it will work OK.
Shrug.
Mikulas Patocka
maintainerQuoted 32 lines · Andrew Morton
Quoted 16 lines · On Fri, 13 Nov 2009 16:07:08 +0900 Akinobu Mita <[email protected]> wrote:
Use hweight32 instead of counting for each bit
Signed-off-by Akinobu Mita <[email protected]>Cc Mikulas Patocka <[email protected]>Cc Al Viro <[email protected]>--- fs/hpfs/super.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)fs/hpfs/super.c +0
-0@@ -119,11 +119,8 @@ unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)unsigned i, count;if (!(bits =hpfs_map_4sectors (s, secno, &qbh,4 )))return 0 ;fs/hpfs/super.c unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) · line 125
Quoted 10 lines
fs/hpfs/super.c +2
-5count =0 ; -for (i =0 ; i <2048 /sizeof (unsigned ); i++) { -unsigned b; -if (!bits[i])continue ; -for (b = bits[i]; b; b>>=1 ) count += b &1 ; - } +for (i =0 ; i <2048 /sizeof (unsigned ); i++) + count +=hweight32 (bits[i]);hpfs_brelse4 (&qbh);return count;Could actualy use
bitmap_weight()here.
Quoted 4 lines
It's a bit naughty, because
bitmap_weight()operates on long*'s, but it will work OK.Shrug.
... and add support for popcnt, so that it's optimized on AMD CPUs.
Mikulas