Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: pkg/barback/lib/src/phase.dart

Issue 26598002: Track the original assets more efficiently in Phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/barback/lib/src/phase.dart
diff --git a/pkg/barback/lib/src/phase.dart b/pkg/barback/lib/src/phase.dart
index af595e742cecf825bb52e83e4be3b447dec08670..c4ba0dfd8a276cb06922a4930ce4b15e9eae34a5 100644
--- a/pkg/barback/lib/src/phase.dart
+++ b/pkg/barback/lib/src/phase.dart
@@ -13,6 +13,7 @@ import 'asset_node.dart';
import 'asset_set.dart';
import 'group_runner.dart';
import 'errors.dart';
+import 'multi_set.dart';
import 'phase_forwarder.dart';
import 'phase_input.dart';
import 'phase_output.dart';
@@ -57,7 +58,6 @@ class Phase {
/// The outputs for this phase.
final _outputs = new Map<AssetId, PhaseOutput>();
- // TODO(nweiz): Don't re-calculate this on the fly all the time.
/// The set of all [AssetNode.origin] properties of the input assets for this
/// phase.
///
@@ -71,8 +71,7 @@ class Phase {
/// a PhaseInput, we must be able to distinguish it from other outputs with
/// the same id. To do so, we check if its origin is in [_inputOrigins]. If
/// so, it's been forwarded unmodified.
- Set<AssetNode> get _inputOrigins =>
- _inputs.values.map((input) => input.input.origin).toSet();
+ final _inputOrigins = new MultiSet<AssetNode>();
/// A stream that emits an event whenever this phase becomes dirty and needs
/// to be run.
@@ -143,9 +142,11 @@ class Phase {
if (exception != null) cascade.reportError(exception);
});
+ _inputOrigins.add(node.origin);
var input = new PhaseInput(this, node, _transformers);
_inputs[node.id] = input;
input.input.whenRemoved.then((_) {
+ _inputOrigins.remove(node.origin);
_inputs.remove(node.id);
_forwarders.remove(node.id).remove();
});

Powered by Google App Engine
This is Rietveld 408576698