commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject [1/2] [lang] LANG-1240: Optimize BitField constructor implementation (closes #119)
Date Mon, 30 May 2016 20:24:28 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master afedbae8a -> 17d6f2163


LANG-1240: Optimize BitField constructor implementation (closes #119)


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/84d52919
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/84d52919
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/84d52919

Branch: refs/heads/master
Commit: 84d52919ec3b3c75f28a185ad7cd87603c3cc4cf
Parents: afedbae
Author: zhanhb <zhanhb@users.noreply.github.com>
Authored: Mon Dec 14 15:29:26 2015 +0800
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Mon May 30 22:23:14 2016 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/BitField.java | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/84d52919/src/main/java/org/apache/commons/lang3/BitField.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/BitField.java b/src/main/java/org/apache/commons/lang3/BitField.java
index 824d242..65b465e 100644
--- a/src/main/java/org/apache/commons/lang3/BitField.java
+++ b/src/main/java/org/apache/commons/lang3/BitField.java
@@ -84,16 +84,7 @@ public class BitField {
      */
     public BitField(final int mask) {
         _mask = mask;
-        int count = 0;
-        int bit_pattern = mask;
-
-        if (bit_pattern != 0) {
-            while ((bit_pattern & 1) == 0) {
-                count++;
-                bit_pattern >>= 1;
-            }
-        }
-        _shift_count = count;
+        _shift_count = mask != 0 ? Integer.numberOfTrailingZeros(mask) : 0;
     }
 
     /**


Mime
View raw message