11package scala .async .internal
22
33import java .util
4+ import java .util .function .{IntConsumer , IntPredicate }
45
56import scala .collection .immutable .IntMap
67
@@ -26,7 +27,7 @@ trait LiveVariables {
2627 var assignsOf = Map [Int , List [Tree ]]()
2728
2829 for ((fld, where) <- liveVarsMap) {
29- where.foreach { (state : Int ) =>
30+ where.foreach { new IntConsumer { def accept (state : Int ): Unit = {
3031 assignsOf get state match {
3132 case None =>
3233 assignsOf += (state -> List (fld))
@@ -35,7 +36,7 @@ trait LiveVariables {
3536 case _ =>
3637 // do nothing
3738 }
38- }
39+ }}}
3940 }
4041
4142 assignsOf
@@ -272,15 +273,21 @@ trait LiveVariables {
272273 val nullOutAt : Map [Tree , StateSet ] =
273274 for ((fld, lastStates) <- lastUsages) yield {
274275 var result = new StateSet
275- lastStates.foreach { s =>
276+ lastStates.foreach( new IntConsumer { def accept ( s : Int ) : Unit = {
276277 if (s != finalState.state) {
277278 val lastAsyncState = asyncStates.find(_.state == s).get
278279 val succNums = lastAsyncState.nextStates
279280 // all successor states that are not indirect predecessors
280281 // 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+ }
282289 }
283- }
290+ }})
284291 (fld, result)
285292 }
286293
0 commit comments