Skip to content

Commit 7b30735

Browse files
committed
Reduce boxing in live variables analysis
1 parent b7ab472 commit 7b30735

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/scala/scala/async/internal/LiveVariables.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ trait LiveVariables {
143143
* A state `i` is contained in the list that is the value to which
144144
* key `j` maps iff control can flow from state `j` to state `i`.
145145
*/
146-
val cfg: Map[Int, Array[Int]] = {
146+
val cfg: IntMap[Array[Int]] = {
147147
var res = IntMap.empty[Array[Int]]
148148

149149
for (as <- asyncStates) res = res.updated(as.state, as.nextStates)
@@ -158,17 +158,16 @@ trait LiveVariables {
158158
def isPred0(state1: Int, state2: Int): Boolean =
159159
if(state1 == state2) false
160160
else if (seen.contains(state1)) false // breaks cycles in the CFG
161-
else cfg get state1 match {
162-
case Some(nextStates) =>
161+
else cfg getOrElse(state1, null) match {
162+
case null => false
163+
case nextStates =>
163164
seen += state1
164165
var i = 0
165166
while (i < nextStates.length) {
166167
if (nextStates(i) == state2 || isPred0(nextStates(i), state2)) return true
167168
i += 1
168169
}
169170
false
170-
case None =>
171-
false
172171
}
173172

174173
isPred0(state1, state2)

0 commit comments

Comments
 (0)