Skip to content

Commit 116165f

Browse files
committed
Don't do a bunch of useless initial recanonicalization
1 parent a333059 commit 116165f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/src/executable/watch.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ Future<void> watch(ExecutableOptions options, StylesheetGraph graph) async {
4343
for (var source in options.sourcesToDestinations.keys) {
4444
var destination = options.sourcesToDestinations[source];
4545
graph.addCanonical(FilesystemImporter('.'), p.toUri(p.canonicalize(source)),
46-
p.toUri(source));
46+
p.toUri(source),
47+
recanonicalize: false);
4748
var success = await watcher.compile(source, destination, ifModified: true);
4849
if (!success && options.stopOnError) {
4950
dirWatcher.events.listen(null).cancel();

lib/src/stylesheet_graph.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ class StylesheetGraph {
8686
/// Returns the set of nodes that need to be recompiled because their imports
8787
/// changed as a result of this stylesheet being added. This does not include
8888
/// the new stylesheet, which can be accessed via `nodes[canonicalUrl]`.
89+
///
90+
/// If [recanonicalize] is `false`, this instead avoids checking downstream
91+
/// nodes' imports and always returns an empty set. It should only be set to
92+
/// `false` when initially adding stylesheets, not when handling future
93+
/// updates.
8994
Set<StylesheetNode> addCanonical(
90-
Importer importer, Uri canonicalUrl, Uri originalUrl) {
95+
Importer importer, Uri canonicalUrl, Uri originalUrl,
96+
{bool recanonicalize = true}) {
9197
var node = _nodes[canonicalUrl];
9298
if (node != null) return const {};
9399

@@ -99,7 +105,9 @@ class StylesheetGraph {
99105
_upstreamNodes(stylesheet, importer, canonicalUrl));
100106
_nodes[canonicalUrl] = node;
101107

102-
return _recanonicalizeImports(importer, canonicalUrl);
108+
return recanonicalize
109+
? _recanonicalizeImports(importer, canonicalUrl)
110+
: const {};
103111
}
104112

105113
/// Returns two maps from non-canonicalized imported URLs in [stylesheet] to

0 commit comments

Comments
 (0)