File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
core/src/main/scala/org/scalajs/macrotaskexecutor Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 1616
1717package org .scalajs .macrotaskexecutor
1818
19- import scala . collection . mutable
19+ import java . util . HashMap
2020import scala .concurrent .{ExecutionContext , ExecutionContextExecutor }
2121import scala .scalajs .js
2222import scala .util .Random
@@ -37,7 +37,7 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
3737 private [this ] val setImmediate : Runnable => Unit = {
3838 if (js.typeOf(js.Dynamic .global.setImmediate) == Undefined ) {
3939 var nextHandle = 1
40- val tasksByHandle = mutable. Map [Int , Runnable ]()
40+ val tasksByHandle = new HashMap [Int , Runnable ]
4141 var currentlyRunningATask = false
4242
4343 def canUsePostMessage (): Boolean = {
@@ -67,17 +67,15 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
6767 if (currentlyRunningATask) {
6868 js.Dynamic .global.setTimeout(() => runIfPresent(handle), 0 )
6969 } else {
70- tasksByHandle.get(handle) match {
71- case Some (task) =>
72- currentlyRunningATask = true
73- try {
74- task.run()
75- } finally {
76- tasksByHandle -= handle
77- currentlyRunningATask = false
78- }
79-
80- case None =>
70+ val task = tasksByHandle.get(handle)
71+ if (task ne null ) {
72+ currentlyRunningATask = true
73+ try {
74+ task.run()
75+ } finally {
76+ tasksByHandle -= handle
77+ currentlyRunningATask = false
78+ }
8179 }
8280 }
8381
You can’t perform that action at this time.
0 commit comments