Skip to content

Commit 005dc1f

Browse files
Format
1 parent cf5b4db commit 005dc1f

4 files changed

Lines changed: 15 additions & 30 deletions

File tree

benchmark/dart2js_output.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ Future<String> getCompiledComponentCode({
188188
}, overReactDep: overReactDep, minify: false);
189189

190190
final baselineCompiledFile = result.getCompiledDart2jsFile('baseline.dart');
191-
final additionalCompiledFile =
192-
result.getCompiledDart2jsFile('additional.dart');
191+
final additionalCompiledFile = result.getCompiledDart2jsFile('additional.dart');
193192

194193
return gitDiffNoIndex(
195194
createNormalizedDart2jsFile(baselineCompiledFile).path,
@@ -222,8 +221,7 @@ Future<String> gitDiffNoIndex(
222221
return result.stdout as String;
223222
}
224223

225-
throw Exception(
226-
'Error diffing files. Exit code: ${result.exitCode} stderr: $stderr');
224+
throw Exception('Error diffing files. Exit code: ${result.exitCode} stderr: $stderr');
227225
}
228226

229227
/// Gets the total size of a single test component, plus usage that sets all props,
@@ -249,10 +247,8 @@ Future<int> getComponentAndUsageSize({
249247
),
250248
}, overReactDep: overReactDep);
251249

252-
final baselineFileSize =
253-
result.getCompiledDart2jsFile('baseline.dart').statSync().size;
254-
final additionalFileSize =
255-
result.getCompiledDart2jsFile('additional.dart').statSync().size;
250+
final baselineFileSize = result.getCompiledDart2jsFile('baseline.dart').statSync().size;
251+
final additionalFileSize = result.getCompiledDart2jsFile('additional.dart').statSync().size;
256252
validateFileSize(baselineFileSize);
257253
validateFileSize(additionalFileSize);
258254

benchmark/dart2js_output/compile.dart

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ Future<BuildResult> compileOverReactProgram({
6666
final webPath = p.join(packagePath, 'web');
6767
webFilesByName.forEach((name, contentsTemplate) {
6868
final filePath = p.join(packagePath, 'web', name);
69-
final partFilename =
70-
p.basenameWithoutExtension(name) + '.over_react.g.dart';
69+
final partFilename = p.basenameWithoutExtension(name) + '.over_react.g.dart';
7170
final contents = contentsTemplate.replaceAll('{{PART_PATH}}', partFilename);
7271

7372
if (!p.isWithin(webPath, filePath)) {
74-
throw ArgumentError.value(
75-
name, 'Filename must be a relative path without any `..`.');
73+
throw ArgumentError.value(name, 'Filename must be a relative path without any `..`.');
7674
}
7775
File(filePath)
7876
..parent.createSync(recursive: true)
@@ -89,8 +87,7 @@ Future<BuildResult> compileOverReactProgram({
8987
runInShell: true,
9088
);
9189
if (pubGetResult.exitCode != 0) {
92-
throw Exception(
93-
'Unexpected `pub get` failure in temporary package: $packagePath\n'
90+
throw Exception('Unexpected `pub get` failure in temporary package: $packagePath\n'
9491
'${pubGetResult.infoForErrorMessage}');
9592
}
9693

@@ -117,8 +114,7 @@ Future<BuildResult> compileOverReactProgram({
117114
..parent.createSync(recursive: true)
118115
..writeAsStringSync(buildResult.stdout.toString());
119116
if (buildResult.exitCode != 0) {
120-
throw Exception(
121-
'Unexpected build failure in temporary package: $packagePath\n'
117+
throw Exception('Unexpected build failure in temporary package: $packagePath\n'
122118
'${buildResult.infoForErrorMessage}');
123119
}
124120

@@ -155,14 +151,10 @@ extension BuildResultUtils on BuildResult {
155151
throw Exception('Compiled file ${compiledFile.path} does not exist');
156152
}
157153
} else {
158-
final candidates = webFolder
159-
.listSync()
160-
.whereType<File>()
161-
.where((f) => f.path.endsWith('.dart.js'))
162-
.toList();
154+
final candidates =
155+
webFolder.listSync().whereType<File>().where((f) => f.path.endsWith('.dart.js')).toList();
163156
if (candidates.length != 1) {
164-
throw Exception(
165-
'Expected a single dart2js output, but found ${candidates.length}:'
157+
throw Exception('Expected a single dart2js output, but found ${candidates.length}:'
166158
'${candidates.map((c) => '\n- ${c.path}')}');
167159
}
168160
compiledFile = candidates.single;

benchmark/dart2js_output/dart2js_normalize.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ String normalizeDart2jsContents(String contents) => contents
1919
return match.group(1)! + '####'; // compile-time constant declarations
2020
})
2121
// Remove newlines in empty function bodies
22-
.replaceAllMapped(
23-
RegExp(r'(function [\w$]+\(\) {)\s+}'), (match) => '${match[1]}}')
22+
.replaceAllMapped(RegExp(r'(function [\w$]+\(\) {)\s+}'), (match) => '${match[1]}}')
2423
// Break up long type inheritance lists onto separate lines
2524
.replaceAllMapped(RegExp(r'(_inheritMany\()([^\n]+)(\]\);)'), (match) {
2625
return '${match[1]}${match[2]!.replaceAll(', ', ',\n ')},\n ${match[3]}';
@@ -38,8 +37,8 @@ String normalizeDart2jsContents(String contents) => contents
3837
final stringContents = match.group(1)!;
3938
String formatted;
4039
try {
41-
formatted = const JsonEncoder.withIndent(' ')
42-
.convert(deepSorted(jsonDecode(stringContents)));
40+
formatted =
41+
const JsonEncoder.withIndent(' ').convert(deepSorted(jsonDecode(stringContents)));
4342
} catch (_) {
4443
formatted = stringContents.replaceAll(',"', ',\n"');
4544
}

benchmark/dart2js_output/source.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ const mainAntiTreeShakingStatements = '''
5050
''';
5151

5252
String propDeclarations(Map propTypesByName) {
53-
return propTypesByName
54-
.mapEntries((name, type) => 'late $type $name;')
55-
.join('\n');
53+
return propTypesByName.mapEntries((name, type) => 'late $type $name;').join('\n');
5654
}
5755

5856
String propReadStatements(Iterable<String> propNames) {

0 commit comments

Comments
 (0)