Unverified Commit 54217bd4 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in `dev/benchmarks` (#118840)

* Remove unnecessary null checks in dev/benchmarks

* empty
parent ec51d327
...@@ -18,9 +18,7 @@ void main() { ...@@ -18,9 +18,7 @@ void main() {
}); });
tearDownAll(() async { tearDownAll(() async {
if (driver != null) {
driver.close(); driver.close();
}
}); });
Future<void> testScrollPerf(String listKey, String summaryName) async { Future<void> testScrollPerf(String listKey, String summaryName) async {
......
...@@ -18,9 +18,7 @@ void main() { ...@@ -18,9 +18,7 @@ void main() {
}); });
tearDownAll(() async { tearDownAll(() async {
if (driver != null) {
driver.close(); driver.close();
}
}); });
Future<void> testScrollPerf(String listKey, String summaryName) async { Future<void> testScrollPerf(String listKey, String summaryName) async {
......
...@@ -34,9 +34,7 @@ void main() { ...@@ -34,9 +34,7 @@ void main() {
}); });
tearDownAll(() async { tearDownAll(() async {
if (driver != null) {
driver.close(); driver.close();
}
}); });
test('initial tree creation', () async { test('initial tree creation', () async {
......
...@@ -159,9 +159,7 @@ class _Tester { ...@@ -159,9 +159,7 @@ class _Tester {
final Stopwatch stopwatch = Stopwatch()..start(); final Stopwatch stopwatch = Stopwatch()..start();
await gesture.moveTo(location, timeStamp: currentTime); await gesture.moveTo(location, timeStamp: currentTime);
stopwatch.stop(); stopwatch.stop();
if (onDataPoint != null) {
onDataPoint(stopwatch.elapsed); onDataPoint(stopwatch.elapsed);
}
await _UntilNextFrame.wait(); await _UntilNextFrame.wait();
} }
......
...@@ -181,9 +181,7 @@ class _Tester { ...@@ -181,9 +181,7 @@ class _Tester {
final Stopwatch stopwatch = Stopwatch()..start(); final Stopwatch stopwatch = Stopwatch()..start();
await gesture.moveTo(location, timeStamp: currentTime); await gesture.moveTo(location, timeStamp: currentTime);
stopwatch.stop(); stopwatch.stop();
if (onDataPoint != null) {
onDataPoint(stopwatch.elapsed); onDataPoint(stopwatch.elapsed);
}
await _UntilNextFrame.wait(); await _UntilNextFrame.wait();
} }
......
...@@ -340,9 +340,7 @@ class ColorItem extends StatelessWidget { ...@@ -340,9 +340,7 @@ class ColorItem extends StatelessWidget {
required this.index, required this.index,
required this.color, required this.color,
this.prefix = '', this.prefix = '',
}) : assert(index != null), });
assert(color != null),
assert(prefix != null);
final int index; final int index;
final Color color; final Color color;
......
...@@ -841,8 +841,7 @@ class Profile { ...@@ -841,8 +841,7 @@ class Profile {
/// If [useCustomWarmUp] is true the benchmark will continue running until /// If [useCustomWarmUp] is true the benchmark will continue running until
/// [stopBenchmark] is called. Otherwise, the benchmark collects the /// [stopBenchmark] is called. Otherwise, the benchmark collects the
/// [kDefaultTotalSampleCount] samples and stops automatically. /// [kDefaultTotalSampleCount] samples and stops automatically.
Profile({required this.name, this.useCustomWarmUp = false}) Profile({required this.name, this.useCustomWarmUp = false});
: assert(name != null);
/// The name of the benchmark that produced this profile. /// The name of the benchmark that produced this profile.
final String name; final String name;
...@@ -1296,13 +1295,6 @@ final Map<String, EngineBenchmarkValueListener> _engineBenchmarkListeners = <Str ...@@ -1296,13 +1295,6 @@ final Map<String, EngineBenchmarkValueListener> _engineBenchmarkListeners = <Str
/// ///
/// If another listener is already registered, overrides it. /// If another listener is already registered, overrides it.
void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListener listener) { void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListener listener) {
if (listener == null) {
throw ArgumentError(
'Listener must not be null. To stop listening to engine benchmark values '
'under label "$name", call stopListeningToEngineBenchmarkValues(\'$name\').',
);
}
if (_engineBenchmarkListeners.containsKey(name)) { if (_engineBenchmarkListeners.containsKey(name)) {
throw StateError( throw StateError(
'A listener for "$name" is already registered.\n' 'A listener for "$name" is already registered.\n'
......
...@@ -83,11 +83,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin ...@@ -83,11 +83,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
String? workingLabel; String? workingLabel;
for (final InlineSpanSemanticsInformation info in inputs) { for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) { if (info.requiresOwnNode) {
if (workingText != null) {
yield InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText); yield InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText);
workingText = ''; workingText = '';
workingLabel = null; workingLabel = null;
}
yield info; yield info;
} else { } else {
workingText += info.text; workingText += info.text;
...@@ -100,11 +98,7 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin ...@@ -100,11 +98,7 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
} }
} }
} }
if (workingText != null) {
yield InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel);
} else {
assert(workingLabel != null); assert(workingLabel != null);
}
} }
Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpanSemanticsInformation> inputs) { Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpanSemanticsInformation> inputs) {
...@@ -113,11 +107,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa ...@@ -113,11 +107,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa
final List<InlineSpanSemanticsInformation> result = <InlineSpanSemanticsInformation>[]; final List<InlineSpanSemanticsInformation> result = <InlineSpanSemanticsInformation>[];
for (final InlineSpanSemanticsInformation info in inputs) { for (final InlineSpanSemanticsInformation info in inputs) {
if (info.requiresOwnNode) { if (info.requiresOwnNode) {
if (workingText != null) {
result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText)); result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel ?? workingText));
workingText = ''; workingText = '';
workingLabel = null; workingLabel = null;
}
result.add(info); result.add(info);
} else { } else {
workingText += info.text; workingText += info.text;
...@@ -130,10 +122,6 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa ...@@ -130,10 +122,6 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa
} }
} }
} }
if (workingText != null) {
result.add(InlineSpanSemanticsInformation(workingText, semanticsLabel: workingLabel));
} else {
assert(workingLabel != null); assert(workingLabel != null);
}
return result; return result;
} }
...@@ -78,11 +78,6 @@ class StockData extends ChangeNotifier { ...@@ -78,11 +78,6 @@ class StockData extends ChangeNotifier {
void _fetchNextChunk() { void _fetchNextChunk() {
_httpClient!.get(_urlToFetch(_nextChunk++)).then<void>((http.Response response) { _httpClient!.get(_urlToFetch(_nextChunk++)).then<void>((http.Response response) {
final String json = response.body; final String json = response.body;
if (json == null) {
debugPrint('Failed to load stock data chunk ${_nextChunk - 1}');
_end();
return;
}
const JsonDecoder decoder = JsonDecoder(); const JsonDecoder decoder = JsonDecoder();
add(decoder.convert(json) as List<dynamic>); add(decoder.convert(json) as List<dynamic>);
if (_nextChunk < _chunkCount) { if (_nextChunk < _chunkCount) {
......
...@@ -85,10 +85,8 @@ class StockHomeState extends State<StockHome> { ...@@ -85,10 +85,8 @@ class StockHomeState extends State<StockHome> {
} }
void _handleStockModeChange(StockMode? value) { 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) { void _handleStockMenu(BuildContext context, _StockMenuItem value) {
switch (value) { switch (value) {
......
...@@ -93,10 +93,8 @@ class StockSettingsState extends State<StockSettings> { ...@@ -93,10 +93,8 @@ class StockSettingsState extends State<StockSettings> {
} }
void sendUpdates(StockConfiguration value) { void sendUpdates(StockConfiguration value) {
if (widget.updater != null) {
widget.updater(value); widget.updater(value);
} }
}
AppBar buildAppBar(BuildContext context) { AppBar buildAppBar(BuildContext context) {
return AppBar( return AppBar(
......
...@@ -18,7 +18,6 @@ class _StockSymbolView extends StatelessWidget { ...@@ -18,7 +18,6 @@ class _StockSymbolView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(stock != null);
final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}'; final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}';
String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%'; String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%';
if (stock.percentChange > 0) { if (stock.percentChange > 0) {
......
...@@ -17,16 +17,7 @@ class StockConfiguration { ...@@ -17,16 +17,7 @@ class StockConfiguration {
required this.debugShowRainbow, required this.debugShowRainbow,
required this.showPerformanceOverlay, required this.showPerformanceOverlay,
required this.showSemanticsDebugger, 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 StockMode stockMode;
final BackupMode backupMode; final BackupMode backupMode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment