summaryrefslogtreecommitdiffstats
path: root/dexdump
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-04-22 13:49:06 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-22 13:49:06 -0700
commitebddfaf55b60c3193b34de6709fde249a5e54432 (patch)
treed3af77dd2f1a04b7f0f9a96395031bb735a628fd /dexdump
parent372eebbde00be3f41c37a4867efad951c193594f (diff)
parented4035bca3233c7a40c4d5679c3f7dfea9516c7e (diff)
downloadandroid_dalvik-ebddfaf55b60c3193b34de6709fde249a5e54432.tar.gz
android_dalvik-ebddfaf55b60c3193b34de6709fde249a5e54432.tar.bz2
android_dalvik-ebddfaf55b60c3193b34de6709fde249a5e54432.zip
am ed4035bc: am d2203aa0: am 1beb43af: merge from open-source master
Merge commit 'ed4035bca3233c7a40c4d5679c3f7dfea9516c7e' into dalvik-dev * commit 'ed4035bca3233c7a40c4d5679c3f7dfea9516c7e': Improve the implementation of countOnes function to use only 12 operations.
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 09b072efb..e5527ca80 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;
}