summaryrefslogtreecommitdiffstats
path: root/dexdump
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-04-22 12:44:36 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2010-04-22 12:44:36 -0700
commit1beb43af9350d47016c0e3ec55c1b2d4230cae7e (patch)
tree695b1d59838e1a210ef5de808df76e23f2e544de /dexdump
parent1dd42bb9da388c55191449b848f9d82dc4673229 (diff)
parente339343c9c698a887681771372ba6cc58a79c707 (diff)
downloadandroid_dalvik-1beb43af9350d47016c0e3ec55c1b2d4230cae7e.tar.gz
android_dalvik-1beb43af9350d47016c0e3ec55c1b2d4230cae7e.tar.bz2
android_dalvik-1beb43af9350d47016c0e3ec55c1b2d4230cae7e.zip
merge from open-source master
Change-Id: Ia08d4f55f5cdced2878777e0812c8cbbf26bb0d6
Diffstat (limited to 'dexdump')
-rw-r--r--dexdump/DexDump.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/dexdump/DexDump.c b/dexdump/DexDump.c
index b3b0839f7..9d9b6be28 100644
--- a/dexdump/DexDump.c
+++ b/dexdump/DexDump.c
@@ -225,20 +225,14 @@ static const char* quotedVisibility(u4 accessFlags)
/*
* Count the number of '1' bits in a word.
- *
- * Having completed this, I'm ready for an interview at Google.
- *
- * TODO? there's a parallel version w/o loops. Performance not currently
- * important.
*/
static int countOnes(u4 val)
{
int count = 0;
- while (val != 0) {
- val &= val-1;
- count++;
- }
+ val = val - ((val >> 1) & 0x55555555);
+ val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
+ count = (((val + (val >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
return count;
}