1.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Mon Nov 03 07:29:46 2014 +0100 1.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Mon Nov 03 11:47:41 2014 +0100 1.3 @@ -19,6 +19,7 @@ 1.4 */ 1.5 package jdk.nashorn.internal.runtime.regexp.joni; 1.6 1.7 +@SuppressWarnings("javadoc") 1.8 public final class BitSet { 1.9 static final int BITS_PER_BYTE = 8; 1.10 public static final int SINGLE_BYTE_SIZE = (1 << BITS_PER_BYTE); 1.11 @@ -34,7 +35,9 @@ 1.12 final StringBuilder buffer = new StringBuilder(); 1.13 buffer.append("BitSet"); 1.14 for (int i=0; i<SINGLE_BYTE_SIZE; i++) { 1.15 - if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) buffer.append("\n "); 1.16 + if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) { 1.17 + buffer.append("\n "); 1.18 + } 1.19 buffer.append(at(i) ? "1" : "0"); 1.20 } 1.21 return buffer.toString(); 1.22 @@ -53,44 +56,62 @@ 1.23 } 1.24 1.25 public void clear() { 1.26 - for (int i=0; i<BITSET_SIZE; i++) bits[i]=0; 1.27 + for (int i=0; i<BITSET_SIZE; i++) { 1.28 + bits[i]=0; 1.29 + } 1.30 } 1.31 1.32 public boolean isEmpty() { 1.33 for (int i=0; i<BITSET_SIZE; i++) { 1.34 - if (bits[i] != 0) return false; 1.35 + if (bits[i] != 0) { 1.36 + return false; 1.37 + } 1.38 } 1.39 return true; 1.40 } 1.41 1.42 public void setRange(final int from, final int to) { 1.43 - for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) set(i); 1.44 + for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) { 1.45 + set(i); 1.46 + } 1.47 } 1.48 1.49 public void invert() { 1.50 - for (int i=0; i<BITSET_SIZE; i++) bits[i] = ~bits[i]; 1.51 + for (int i=0; i<BITSET_SIZE; i++) { 1.52 + bits[i] = ~bits[i]; 1.53 + } 1.54 } 1.55 1.56 public void invertTo(final BitSet to) { 1.57 - for (int i=0; i<BITSET_SIZE; i++) to.bits[i] = ~bits[i]; 1.58 + for (int i=0; i<BITSET_SIZE; i++) { 1.59 + to.bits[i] = ~bits[i]; 1.60 + } 1.61 } 1.62 1.63 public void and(final BitSet other) { 1.64 - for (int i=0; i<BITSET_SIZE; i++) bits[i] &= other.bits[i]; 1.65 + for (int i=0; i<BITSET_SIZE; i++) { 1.66 + bits[i] &= other.bits[i]; 1.67 + } 1.68 } 1.69 1.70 public void or(final BitSet other) { 1.71 - for (int i=0; i<BITSET_SIZE; i++) bits[i] |= other.bits[i]; 1.72 + for (int i=0; i<BITSET_SIZE; i++) { 1.73 + bits[i] |= other.bits[i]; 1.74 + } 1.75 } 1.76 1.77 public void copy(final BitSet other) { 1.78 - for (int i=0; i<BITSET_SIZE; i++) bits[i] = other.bits[i]; 1.79 + for (int i=0; i<BITSET_SIZE; i++) { 1.80 + bits[i] = other.bits[i]; 1.81 + } 1.82 } 1.83 1.84 public int numOn() { 1.85 int num = 0; 1.86 for (int i=0; i<SINGLE_BYTE_SIZE; i++) { 1.87 - if (at(i)) num++; 1.88 + if (at(i)) { 1.89 + num++; 1.90 + } 1.91 } 1.92 return num; 1.93 } 1.94 @@ -99,9 +120,12 @@ 1.95 return 1 << (pos % SINGLE_BYTE_SIZE); 1.96 } 1.97 1.98 - private static int log2(int n){ 1.99 + private static int log2(final int np) { 1.100 int log = 0; 1.101 - while ((n >>>= 1) != 0) log++; 1.102 + int n = np; 1.103 + while ((n >>>= 1) != 0) { 1.104 + log++; 1.105 + } 1.106 return log; 1.107 } 1.108