harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessewil...@apache.org
Subject svn commit: r888654 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java
Date Wed, 09 Dec 2009 00:12:48 GMT
Author: jessewilson
Date: Wed Dec  9 00:12:47 2009
New Revision: 888654

URL: http://svn.apache.org/viewvc?rev=888654&view=rev
Log:
Fix for HARMONY-6385; EnumSet.compilmentOf() broken for cardinality 128, 192, etc.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java?rev=888654&r1=888653&r2=888654&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HugeEnumSet.java
Wed Dec  9 00:12:47 2009
@@ -159,21 +159,17 @@
     
     @Override
     protected void complement() {
-        if (0 != enums.length) {
-            bitsIndex = enums.length / BIT_IN_LONG;
+        size = 0;
+        for (int i = 0, length = bits.length; i < length; i++) {
+            long b = ~bits[i];
 
-            size = 0;
-            int bitCount = 0;
-            for (int i = 0; i <= bitsIndex; i++) {
-                bits[i] = ~bits[i];
-                bitCount = Long.bitCount(bits[i]);
-                size += bitCount;
-            }
-            bits[bitsIndex] &= (-1l >>> (BIT_IN_LONG - enums.length
-                    % BIT_IN_LONG));
-            size -= bitCount;
-            bitCount = Long.bitCount(bits[bitsIndex]);
-            size += bitCount;
+            // zero out unused bits on the last element
+            if (i == length - 1) {
+                b &= -1L >>> (BIT_IN_LONG - (enums.length % BIT_IN_LONG));
+            }
+
+            size += Long.bitCount(b);
+            bits[i] = b;
         }
     }
     



Mime
View raw message