[jruby-joni] 65/194: bitset cleanup
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:27 UTC 2018
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit 6df13b0d2172719e24c350aa2f99cca0bd9c2289
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Sat Dec 30 15:32:05 2017 +0100
bitset cleanup
---
src/org/joni/BitSet.java | 33 ++++++++++++++-------------------
src/org/joni/ast/CClassNode.java | 2 +-
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/src/org/joni/BitSet.java b/src/org/joni/BitSet.java
index 2e53217..4ed9e22 100644
--- a/src/org/joni/BitSet.java
+++ b/src/org/joni/BitSet.java
@@ -26,22 +26,7 @@ public final class BitSet {
public static final int BITSET_SIZE = (SINGLE_BYTE_SIZE / BITS_IN_ROOM);
static final int ROOM_SHIFT = log2(BITS_IN_ROOM);
- final int[] bits = new int[BITSET_SIZE];
-
- private static final int BITS_TO_STRING_WRAP = 4;
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("BitSet");
- for (int i=0; i<SINGLE_BYTE_SIZE; i++) {
- if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) buffer.append("\n ");
- buffer.append(at(i) ? "1" : "0");
- }
- return buffer.toString();
- }
-
- public int getBits(int pos) {
- return bits[pos];
- }
+ public final int[] bits = new int[BITSET_SIZE];
public boolean at(int pos) {
return (bits[pos >>> ROOM_SHIFT] & bit(pos)) != 0;
@@ -94,11 +79,11 @@ public final class BitSet {
for (int i=0; i<BITSET_SIZE; i++) bits[i] |= other.bits[i];
}
- public void copy(BitSet other) {
+ void copy(BitSet other) {
for (int i=0; i<BITSET_SIZE; i++) bits[i] = other.bits[i];
}
- public int numOn() {
+ int numOn() {
int num = 0;
for (int i=0; i<SINGLE_BYTE_SIZE; i++) {
if (at(i)) num++;
@@ -106,7 +91,7 @@ public final class BitSet {
return num;
}
- static int bit(int pos){
+ private static int bit(int pos){
return 1 << (pos % SINGLE_BYTE_SIZE);
}
@@ -116,4 +101,14 @@ public final class BitSet {
return log;
}
+ private static final int BITS_TO_STRING_WRAP = 4;
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("BitSet");
+ for (int i=0; i<SINGLE_BYTE_SIZE; i++) {
+ if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) buffer.append("\n ");
+ buffer.append(at(i) ? "1" : "0");
+ }
+ return buffer.toString();
+ }
}
diff --git a/src/org/joni/ast/CClassNode.java b/src/org/joni/ast/CClassNode.java
index 92fb469..6930a15 100644
--- a/src/org/joni/ast/CClassNode.java
+++ b/src/org/joni/ast/CClassNode.java
@@ -114,7 +114,7 @@ public final class CClassNode extends Node {
}
for (int i = 0; i < BitSet.BITSET_SIZE; i++) {
- int b1 = bs.getBits(i);
+ int b1 = bs.bits[i];
if (b1 != 0) {
if ((b1 & (b1 - 1)) == 0 && c == -1) {
c = BitSet.BITS_IN_ROOM * i + Integer.bitCount(b1 - 1);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list