refactor: Modernize switch; use switch-expressions and no break; (#3133)

Replaces the switch cases that can be replaces with switch expressions
and removes `break;` where it isn't needed.

https://dart.dev/language/branches#switch-statements
This commit is contained in:
Lukas Klingsbo
2024-04-18 23:41:08 +02:00
committed by GitHub
parent 69f5c388ce
commit b283b82f6c
29 changed files with 183 additions and 425 deletions

View File

@ -95,26 +95,19 @@ class WorkerOvermind extends Component
pathFinderData: game.pathFinderData,
);
final List<List<IntVector2>> paths;
switch (isolateHud.computeType) {
case ComputeType.isolate:
paths = await isolateCompute(
final paths = switch (isolateHud.computeType) {
ComputeType.isolate => await isolateCompute(
_calculateWork,
calculateWorkData,
);
break;
case ComputeType.synchronous:
paths = _calculateWork(
),
ComputeType.synchronous => _calculateWork(
calculateWorkData,
);
break;
case ComputeType.compute:
paths = await compute(
),
ComputeType.compute => await compute(
_calculateWork,
calculateWorkData,
);
break;
}
),
};
for (var i = 0; i < paths.length; i++) {
idleWorkers[i].issueWork(