From d64cf16cf2c6aea7668e922f9510900bf298c21f Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 30 Jun 2020 18:16:04 +0000 Subject: [PATCH] Avoid throwing an exception for hasTerminal See https://github.com/dart-lang/test/issues/1261 Throwing and immediately catching an exception has negative implications for debugging and pausing on thrown exceptions. The exception is not needed provided we duplicate a small bit of knowledge - that the function to retrieve terminal size would return a non-list. Change-Id: Ic92f7c0480d58963e857c699aa0251eedeb3e627 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152922 Commit-Queue: Nate Bosch Auto-Submit: Nate Bosch Reviewed-by: Zichang Guo --- sdk/lib/_internal/vm/bin/stdio_patch.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sdk/lib/_internal/vm/bin/stdio_patch.dart b/sdk/lib/_internal/vm/bin/stdio_patch.dart index bc3222151a81..cf02d62b81e6 100644 --- a/sdk/lib/_internal/vm/bin/stdio_patch.dart +++ b/sdk/lib/_internal/vm/bin/stdio_patch.dart @@ -126,15 +126,7 @@ class Stdin { @patch class Stdout { @patch - bool _hasTerminal(int fd) { - try { - _terminalSize(fd); - return true; - } catch (_) { - return false; - } - } - + bool _hasTerminal(int fd) => _getTerminalSize(fd) is List; @patch int _terminalColumns(int fd) => _terminalSize(fd)[0]; @patch