diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-04-22 13:49:06 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-04-22 13:49:06 -0700 |
commit | ebddfaf55b60c3193b34de6709fde249a5e54432 (patch) | |
tree | d3af77dd2f1a04b7f0f9a96395031bb735a628fd /dexdump | |
parent | 372eebbde00be3f41c37a4867efad951c193594f (diff) | |
parent | ed4035bca3233c7a40c4d5679c3f7dfea9516c7e (diff) | |
download | android_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.c | 12 |
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; } |