Faster hot reload (#8600)
This implements the `DartDependencySetBuilder` completely in Dart instead of calling out to `sky_snapshot` (Linux/Mac) or `gen_snapshot` (Windows) and allows us to use the same code path on all supported host platforms. It also slightly reduces hot reload times on Linux from ~750ms to ~690ms for the unchanged flutter_gallery app and significantly reduces hot reload times on Windows from almost 1.5s to just slightly slower than on Linux. This change will also allow us to retire `sky_snapshot` completely in the future.
This commit is contained in:
committed by
GitHub
parent
3b4f6b1ae0
commit
644e7b131d
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:flutter_tools/src/dart/dependencies.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@@ -17,7 +18,7 @@ void main() {
|
||||
final String mainPath = fs.path.join(testPath, 'main.dart');
|
||||
final String packagesPath = fs.path.join(testPath, '.packages');
|
||||
final DartDependencySetBuilder builder =
|
||||
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
|
||||
new DartDependencySetBuilder(mainPath, packagesPath);
|
||||
final Set<String> dependencies = builder.build();
|
||||
expect(dependencies.contains(fs.path.canonicalize(mainPath)), isTrue);
|
||||
expect(dependencies.contains(fs.path.canonicalize(fs.path.join(testPath, 'foo.dart'))), isTrue);
|
||||
@@ -27,13 +28,12 @@ void main() {
|
||||
final String mainPath = fs.path.join(testPath, 'main.dart');
|
||||
final String packagesPath = fs.path.join(testPath, '.packages');
|
||||
final DartDependencySetBuilder builder =
|
||||
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
|
||||
new DartDependencySetBuilder(mainPath, packagesPath);
|
||||
try {
|
||||
builder.build();
|
||||
fail('expect an assertion to be thrown.');
|
||||
} catch (e) {
|
||||
expect(e, const isInstanceOf<String>());
|
||||
expect(e.contains('unexpected token \'bad\''), isTrue);
|
||||
} on AnalyzerErrorGroup catch (e) {
|
||||
expect(e.toString(), contains('foo.dart: Expected a string literal'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
bad programmer!
|
||||
import bad programmer!
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
final String barPath = fs.path.join(testPath, 'lib', 'bar.dart');
|
||||
final String packagesPath = fs.path.join(testPath, '.packages');
|
||||
final DartDependencySetBuilder builder =
|
||||
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
|
||||
new DartDependencySetBuilder(mainPath, packagesPath);
|
||||
final DependencyChecker dependencyChecker =
|
||||
new DependencyChecker(builder, null);
|
||||
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
final String packagesPath = fs.path.join(testPath, '.packages');
|
||||
|
||||
final DartDependencySetBuilder builder =
|
||||
new DartDependencySetBuilder(mainPath, testPath, packagesPath);
|
||||
new DartDependencySetBuilder(mainPath, packagesPath);
|
||||
final DependencyChecker dependencyChecker =
|
||||
new DependencyChecker(builder, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user