1
1
package scala .async .internal
2
2
3
3
import java .util
4
+ import java .util .function .{IntConsumer , IntPredicate }
4
5
5
6
import scala .collection .immutable .IntMap
6
7
@@ -26,7 +27,7 @@ trait LiveVariables {
26
27
var assignsOf = Map [Int , List [Tree ]]()
27
28
28
29
for ((fld, where) <- liveVarsMap) {
29
- where.foreach { (state : Int ) =>
30
+ where.foreach { new IntConsumer { def accept (state : Int ): Unit = {
30
31
assignsOf get state match {
31
32
case None =>
32
33
assignsOf += (state -> List (fld))
@@ -35,7 +36,7 @@ trait LiveVariables {
35
36
case _ =>
36
37
// do nothing
37
38
}
38
- }
39
+ }}}
39
40
}
40
41
41
42
assignsOf
@@ -272,15 +273,21 @@ trait LiveVariables {
272
273
val nullOutAt : Map [Tree , StateSet ] =
273
274
for ((fld, lastStates) <- lastUsages) yield {
274
275
var result = new StateSet
275
- lastStates.foreach { s =>
276
+ lastStates.foreach( new IntConsumer { def accept ( s : Int ) : Unit = {
276
277
if (s != finalState.state) {
277
278
val lastAsyncState = asyncStates.find(_.state == s).get
278
279
val succNums = lastAsyncState.nextStates
279
280
// all successor states that are not indirect predecessors
280
281
// filter out successor states where the field is live at the entry
281
- util.Arrays .stream(succNums).filter(num => ! isPred(num, s)).filter(num => ! LVentry (num).contains(fld.symbol)).forEach(result += _)
282
+ var i = 0
283
+ while (i < succNums.length) {
284
+ val num = succNums(i)
285
+ if (! isPred(num, s) && ! LVentry (num).contains(fld.symbol))
286
+ result += num
287
+ i += 1
288
+ }
282
289
}
283
- }
290
+ }})
284
291
(fld, result)
285
292
}
286
293
0 commit comments