Call isatty() way less frequently
This commit is contained in:
parent
ac55efa5df
commit
1186261b3b
1 changed files with 2 additions and 1 deletions
3
main.c
3
main.c
|
@ -139,6 +139,7 @@ error_io:
|
||||||
static ssize_t dump_fd(int fd) {
|
static ssize_t dump_fd(int fd) {
|
||||||
void *buf;
|
void *buf;
|
||||||
ssize_t total = 0;
|
ssize_t total = 0;
|
||||||
|
int tty = isatty(fileno(stdout));
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (fstat(fd, &st) < 0) {
|
if (fstat(fd, &st) < 0) {
|
||||||
|
@ -163,7 +164,7 @@ static ssize_t dump_fd(int fd) {
|
||||||
size_t left = len - i,
|
size_t left = len - i,
|
||||||
linesz = left < ZXDUMP_STRIDE_LINE? left: ZXDUMP_STRIDE_LINE;
|
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;
|
goto error_dump_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue