From 54217bd4b19e5ba1a06d3101ca9f1dae51766344 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 19 Jan 2023 20:04:11 -0800 Subject: [PATCH] Remove unnecessary null checks in `dev/benchmarks` (#118840) * Remove unnecessary null checks in dev/benchmarks * empty --- .../test_driver/scroll_perf_bad_test.dart | 4 +-- .../test_driver/scroll_perf_test.dart | 4 +-- .../test_driver/semantics_perf_test.dart | 4 +-- .../web/bench_mouse_region_grid_hover.dart | 4 +-- .../bench_mouse_region_mixed_grid_hover.dart | 4 +-- .../lib/src/web/bench_text_layout.dart | 4 +-- .../macrobenchmarks/lib/src/web/recorder.dart | 10 +------ .../language/sync_star_semantics_bench.dart | 28 ++++++------------- .../test_apps/stocks/lib/stock_data.dart | 5 ---- .../test_apps/stocks/lib/stock_home.dart | 4 +-- .../test_apps/stocks/lib/stock_settings.dart | 4 +-- .../stocks/lib/stock_symbol_viewer.dart | 1 - .../test_apps/stocks/lib/stock_types.dart | 11 +------- 13 files changed, 18 insertions(+), 69 deletions(-) diff --git a/dev/benchmarks/complex_layout/test_driver/scroll_perf_bad_test.dart b/dev/benchmarks/complex_layout/test_driver/scroll_perf_bad_test.dart index 6778b55af7bc..e788462557e5 100644 --- a/dev/benchmarks/complex_layout/test_driver/scroll_perf_bad_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/scroll_perf_bad_test.dart @@ -18,9 +18,7 @@ void main() { }); tearDownAll(() async { - if (driver != null) { - driver.close(); - } + driver.close(); }); Future testScrollPerf(String listKey, String summaryName) async { diff --git a/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart b/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart index 0291e084cff9..aaa8636036db 100644 --- a/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart @@ -18,9 +18,7 @@ void main() { }); tearDownAll(() async { - if (driver != null) { - driver.close(); - } + driver.close(); }); Future testScrollPerf(String listKey, String summaryName) async { diff --git a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart index ecd926b37606..501b751e8bda 100644 --- a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart @@ -34,9 +34,7 @@ void main() { }); tearDownAll(() async { - if (driver != null) { - driver.close(); - } + driver.close(); }); test('initial tree creation', () async { diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart index f9b1ad0fda32..a65252201e11 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart @@ -159,9 +159,7 @@ class _Tester { final Stopwatch stopwatch = Stopwatch()..start(); await gesture.moveTo(location, timeStamp: currentTime); stopwatch.stop(); - if (onDataPoint != null) { - onDataPoint(stopwatch.elapsed); - } + onDataPoint(stopwatch.elapsed); await _UntilNextFrame.wait(); } diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart index 16a6c22d2ecb..ddd60d1a6f7c 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_mixed_grid_hover.dart @@ -181,9 +181,7 @@ class _Tester { final Stopwatch stopwatch = Stopwatch()..start(); await gesture.moveTo(location, timeStamp: currentTime); stopwatch.stop(); - if (onDataPoint != null) { - onDataPoint(stopwatch.elapsed); - } + onDataPoint(stopwatch.elapsed); await _UntilNextFrame.wait(); } diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart index 0d07241dfd56..e1156dd38304 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart @@ -340,9 +340,7 @@ class ColorItem extends StatelessWidget { required this.index, required this.color, this.prefix = '', - }) : assert(index != null), - assert(color != null), - assert(prefix != null); + }); final int index; final Color color; diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart index a543a32686ba..d9523b5bc624 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart @@ -841,8 +841,7 @@ class Profile { /// If [useCustomWarmUp] is true the benchmark will continue running until /// [stopBenchmark] is called. Otherwise, the benchmark collects the /// [kDefaultTotalSampleCount] samples and stops automatically. - Profile({required this.name, this.useCustomWarmUp = false}) - : assert(name != null); + Profile({required this.name, this.useCustomWarmUp = false}); /// The name of the benchmark that produced this profile. final String name; @@ -1296,13 +1295,6 @@ final Map _engineBenchmarkListeners = combineSemanticsInfoSyncStar(List combineSemanticsInfoSyncStar(List combineSemanticsInfoList(List inputs) { @@ -113,11 +107,9 @@ Iterable combineSemanticsInfoList(List result = []; for (final InlineSpanSemanticsInformation info in inputs) { if (info.requiresOwnNode) { - if (workingText != null) { - result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText)); - workingText = ''; - workingLabel = null; - } + result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText)); + workingText = ''; + workingLabel = null; result.add(info); } else { workingText += info.text; @@ -130,10 +122,6 @@ Iterable combineSemanticsInfoList(List((http.Response response) { final String json = response.body; - if (json == null) { - debugPrint('Failed to load stock data chunk ${_nextChunk - 1}'); - _end(); - return; - } const JsonDecoder decoder = JsonDecoder(); add(decoder.convert(json) as List); if (_nextChunk < _chunkCount) { diff --git a/dev/benchmarks/test_apps/stocks/lib/stock_home.dart b/dev/benchmarks/test_apps/stocks/lib/stock_home.dart index c0592a24aeb5..b42663554784 100644 --- a/dev/benchmarks/test_apps/stocks/lib/stock_home.dart +++ b/dev/benchmarks/test_apps/stocks/lib/stock_home.dart @@ -85,9 +85,7 @@ class StockHomeState extends State { } void _handleStockModeChange(StockMode? value) { - if (widget.updater != null) { - widget.updater(widget.configuration.copyWith(stockMode: value)); - } + widget.updater(widget.configuration.copyWith(stockMode: value)); } void _handleStockMenu(BuildContext context, _StockMenuItem value) { diff --git a/dev/benchmarks/test_apps/stocks/lib/stock_settings.dart b/dev/benchmarks/test_apps/stocks/lib/stock_settings.dart index 460ad3a120d3..931e650cfdc9 100644 --- a/dev/benchmarks/test_apps/stocks/lib/stock_settings.dart +++ b/dev/benchmarks/test_apps/stocks/lib/stock_settings.dart @@ -93,9 +93,7 @@ class StockSettingsState extends State { } void sendUpdates(StockConfiguration value) { - if (widget.updater != null) { - widget.updater(value); - } + widget.updater(value); } AppBar buildAppBar(BuildContext context) { diff --git a/dev/benchmarks/test_apps/stocks/lib/stock_symbol_viewer.dart b/dev/benchmarks/test_apps/stocks/lib/stock_symbol_viewer.dart index 16fb2f56cb35..02d6202d8e15 100644 --- a/dev/benchmarks/test_apps/stocks/lib/stock_symbol_viewer.dart +++ b/dev/benchmarks/test_apps/stocks/lib/stock_symbol_viewer.dart @@ -18,7 +18,6 @@ class _StockSymbolView extends StatelessWidget { @override Widget build(BuildContext context) { - assert(stock != null); final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}'; String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%'; if (stock.percentChange > 0) { diff --git a/dev/benchmarks/test_apps/stocks/lib/stock_types.dart b/dev/benchmarks/test_apps/stocks/lib/stock_types.dart index 5c3e5c94ef9f..af2a9305c362 100644 --- a/dev/benchmarks/test_apps/stocks/lib/stock_types.dart +++ b/dev/benchmarks/test_apps/stocks/lib/stock_types.dart @@ -17,16 +17,7 @@ class StockConfiguration { required this.debugShowRainbow, required this.showPerformanceOverlay, required this.showSemanticsDebugger, - }) : assert(stockMode != null), - assert(backupMode != null), - assert(debugShowGrid != null), - assert(debugShowSizes != null), - assert(debugShowBaselines != null), - assert(debugShowLayers != null), - assert(debugShowPointers != null), - assert(debugShowRainbow != null), - assert(showPerformanceOverlay != null), - assert(showSemanticsDebugger != null); + }); final StockMode stockMode; final BackupMode backupMode;