@@ -39,38 +39,42 @@ class MutableBitSetDecorator(protected val bs: mutable.BitSet) {
39
39
40
40
private def shiftLeftInPlace (shiftBy : Int ): Unit = {
41
41
42
- val bitOffset = shiftBy & WordMask
43
- val wordOffset = shiftBy >>> LogWL
44
-
45
42
var significantWordCount = bs.nwords
46
43
while (significantWordCount > 0 && bs.word(significantWordCount - 1 ) == 0 ) {
47
44
significantWordCount -= 1
48
45
}
49
46
50
- if (bitOffset == 0 ) {
51
- val newSize = significantWordCount + wordOffset
52
- require(newSize <= MaxSize )
53
- ensureCapacity(newSize)
54
- System .arraycopy(bs.elems, 0 , bs.elems, wordOffset, significantWordCount)
55
- } else {
56
- val revBitOffset = WordLength - bitOffset
57
- val extraBits = bs.elems(significantWordCount - 1 ) >>> revBitOffset
58
- val extraWordCount = if (extraBits == 0 ) 0 else 1
59
- val newSize = significantWordCount + wordOffset + extraWordCount
60
- require(newSize <= MaxSize )
61
- ensureCapacity(newSize)
62
- var i = significantWordCount - 1
63
- var previous = bs.elems(i)
64
- while (i > 0 ) {
65
- val current = bs.elems(i - 1 )
66
- bs.elems(i + wordOffset) = (current >>> revBitOffset) | (previous << bitOffset)
67
- previous = current
68
- i -= 1
47
+ if (significantWordCount > 0 ) {
48
+
49
+ val bitOffset = shiftBy & WordMask
50
+ val wordOffset = shiftBy >>> LogWL
51
+
52
+ if (bitOffset == 0 ) {
53
+ val newSize = significantWordCount + wordOffset
54
+ require(newSize <= MaxSize )
55
+ ensureCapacity(newSize)
56
+ System .arraycopy(bs.elems, 0 , bs.elems, wordOffset, significantWordCount)
57
+ } else {
58
+ val revBitOffset = WordLength - bitOffset
59
+ val extraBits = bs.elems(significantWordCount - 1 ) >>> revBitOffset
60
+ val extraWordCount = if (extraBits == 0 ) 0 else 1
61
+ val newSize = significantWordCount + wordOffset + extraWordCount
62
+ require(newSize <= MaxSize )
63
+ ensureCapacity(newSize)
64
+ var i = significantWordCount - 1
65
+ var previous = bs.elems(i)
66
+ while (i > 0 ) {
67
+ val current = bs.elems(i - 1 )
68
+ bs.elems(i + wordOffset) = (current >>> revBitOffset) | (previous << bitOffset)
69
+ previous = current
70
+ i -= 1
71
+ }
72
+ bs.elems(wordOffset) = previous << bitOffset
73
+ if (extraWordCount != 0 ) bs.elems(newSize - 1 ) = extraBits
69
74
}
70
- bs.elems(wordOffset) = previous << bitOffset
71
- if (extraWordCount != 0 ) bs.elems(newSize - 1 ) = extraBits
75
+
76
+ java.util. Arrays .fill( bs.elems, 0 , wordOffset, 0 )
72
77
}
73
- java.util.Arrays .fill(bs.elems, 0 , wordOffset, 0 )
74
78
}
75
79
76
80
private def shiftRightInPlace (shiftBy : Int ): Unit = {
0 commit comments