Skip to content

Commit 5792db5

Browse files
committed
Stop using Future.wait.
1 parent 97c653b commit 5792db5

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

build_runner_core/lib/src/asset_graph/graph.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,12 @@ class AssetGraph implements GeneratedAssetHider {
253253
AssetReader digestReader,
254254
) async {
255255
digestReader.cache.invalidate(ids);
256-
await Future.wait(
257-
ids.map((id) async {
258-
final digest = await digestReader.digest(id);
259-
updateNode(id, (nodeBuilder) {
260-
nodeBuilder.digest = digest;
261-
});
262-
}),
263-
);
256+
for (final id in ids) {
257+
final digest = await digestReader.digest(id);
258+
updateNode(id, (nodeBuilder) {
259+
nodeBuilder.digest = digest;
260+
});
261+
}
264262
}
265263

266264
/// Changes [id] and its transitive`primaryOutput`s to `missingSource` nodes.

build_runner_core/lib/src/generate/asset_tracker.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,16 @@ class AssetTracker {
108108
var originalGraphSources = assetGraph.sources.toSet();
109109
var preExistingSources = originalGraphSources.intersection(inputSources)
110110
..addAll(internalSources.where(assetGraph.contains));
111-
var modifyChecks = preExistingSources.map((id) async {
111+
for (final id in preExistingSources) {
112112
var node = assetGraph.get(id)!;
113113
var originalDigest = node.digest;
114-
if (originalDigest == null) return;
114+
if (originalDigest == null) continue;
115115
_reader.cache.invalidate([id]);
116116
var currentDigest = await _reader.digest(id);
117117
if (currentDigest != originalDigest) {
118118
updates[id] = ChangeType.MODIFY;
119119
}
120-
});
121-
await Future.wait(modifyChecks);
120+
}
122121
return updates;
123122
}
124123

build_runner_core/lib/src/generate/build.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,13 @@ class Build {
561561
PostBuildPhase phase,
562562
) async {
563563
var actionNum = 0;
564-
var outputLists = await Future.wait(
565-
phase.builderActions.map(
566-
(action) => _runPostBuildAction(phaseNum, actionNum++, action),
567-
),
568-
);
569-
return outputLists.fold<List<AssetId>>(
570-
<AssetId>[],
571-
(combined, next) => combined..addAll(next),
572-
);
564+
final result = <AssetId>[];
565+
for (final builderAction in phase.builderActions) {
566+
result.addAll(
567+
await _runPostBuildAction(phaseNum, actionNum++, builderAction),
568+
);
569+
}
570+
return result;
573571
}
574572

575573
Future<Iterable<AssetId>> _runPostBuildAction(

0 commit comments

Comments
 (0)