Skip to content

Commit b7ab472

Browse files
committed
Fix logic error in StateSet
1 parent a651d82 commit b7ab472

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/scala/scala/async/internal/StateSet.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import scala.collection.JavaConverters.{asScalaIteratorConverter, iterableAsScal
2121
final class StateSet {
2222
private var bitSet = new java.util.BitSet()
2323
private var caseSet = new util.HashSet[Integer]()
24-
def +=(stateId: Int): Unit = if (stateId > 0) bitSet.set(stateId) else caseSet.add(stateId)
25-
def contains(stateId: Int): Boolean = if (stateId > 0 && stateId < 1024) bitSet.get(stateId) else caseSet.contains(stateId)
24+
def +=(stateId: Int): Unit = if (storeInBitSet(stateId)) bitSet.set(stateId) else caseSet.add(stateId)
25+
def contains(stateId: Int): Boolean = if (storeInBitSet(stateId)) bitSet.get(stateId) else caseSet.contains(stateId)
26+
private def storeInBitSet(stateId: Int) = {
27+
stateId > 0 && stateId < 1024
28+
}
2629
def iterator: Iterator[Integer] = {
2730
bitSet.stream().iterator().asScala ++ caseSet.asScala.iterator
2831
}

0 commit comments

Comments
 (0)