Update with more review feedback from jonahwilliams * Remove the identity() function. * Make _flattenMap private. * Don't bother with ungrowable lists.
diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index 6d3301d..a5a3719 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart
@@ -136,8 +136,8 @@ print('$clock ELAPSED TIME: $bold${elapsedTime(start)}$reset for $commandDescription in $relativeWorkingDir: '); if (output != null) { - output.stdout = flattenToString(await savedStdout); - output.stderr = flattenToString(await savedStderr); + output.stdout = _flattenToString(await savedStdout); + output.stderr = _flattenToString(await savedStderr); } // If the test is flaky we don't care about the actual exit. @@ -156,8 +156,8 @@ break; case OutputMode.capture: case OutputMode.discard: - stdout.writeln(flattenToString(await savedStdout)); - stderr.writeln(flattenToString(await savedStderr)); + stdout.writeln(_flattenToString(await savedStdout)); + stderr.writeln(_flattenToString(await savedStderr)); break; } print( @@ -171,11 +171,9 @@ } } -T identity<T>(T x) => x; - /// Flattens a nested list of UTF-8 code units into a single string. -String flattenToString(List<List<int>> chunks) => - utf8.decode(chunks.expand<int>(identity).toList(growable: false)); +String _flattenToString(List<List<int>> chunks) => + utf8.decode(chunks.expand<int>((List<int> ints) => ints).toList()); /// Specifies what to do with command output from [runCommand]. enum OutputMode { print, capture, discard }