From 1186261b3be58cdad08d265ef5652e10a69b8140 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 11 Sep 2023 13:50:24 -0400 Subject: Call isatty() way less frequently --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 9608211..3e33516 100644 --- a/main.c +++ b/main.c @@ -139,6 +139,7 @@ error_io: static ssize_t dump_fd(int fd) { void *buf; ssize_t total = 0; + int tty = isatty(fileno(stdout)); struct stat st; if (fstat(fd, &st) < 0) { @@ -163,7 +164,7 @@ static ssize_t dump_fd(int fd) { size_t left = len - i, linesz = left < ZXDUMP_STRIDE_LINE? left: ZXDUMP_STRIDE_LINE; - if (dump_line(offset, buf, linesz, isatty(fileno(stdout))) < 0) { + if (dump_line(offset, buf, linesz, tty) < 0) { goto error_dump_line; } -- cgit v1.2.3