summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2018-05-05 10:54:59 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-05-05 10:54:59 -0700
commitd15117c98a071b8fd30fb163fc45cb37db760654 (patch)
treef6c015b5899b4734d7090c2157bd44a23fc5df2e
parent4f410f3ed29fdb0f98be1e01930ba1a909a36ef0 (diff)
downloadxorg-util-makedepend-d15117c98a071b8fd30fb163fc45cb37db760654.tar.gz
Simplify writing of output lines to Makefile
Instead of writing everything to a temporary buffer, and then using fwrite() to have it fputc() one character at a time into the stdio buffer, just use fprintf() directly to save a copy and write in larger blocks. Testing on Solaris on makedepend's own source files showed a reduction in memcpy's from 4037 to 3108, and in _dowrite calls in stdio from 1173 to 168, but no change in actual write calls from stdio's buffer to the file. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--pr.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/pr.c b/pr.c
index 9a49635..4744d56 100644
--- a/pr.c
+++ b/pr.c
@@ -108,7 +108,6 @@ pr(struct inclist *ip, const char *file, const char *base)
static int current_len;
register int len, i;
const char * quoted;
- char buf[ BUFSIZ ];
char quotebuf[ BUFSIZ ];
printed = TRUE;
@@ -116,15 +115,13 @@ pr(struct inclist *ip, const char *file, const char *base)
len = strlen(quoted)+1;
if (current_len + len > width || file != lastfile) {
lastfile = file;
- snprintf(buf, sizeof(buf), "\n%s%s%s: %s",
+ current_len = fprintf(stdout, "\n%s%s%s: %s",
objprefix, base, objsuffix, quoted);
- len = current_len = strlen(buf);
}
else {
- snprintf(buf, sizeof(buf), " %s", quoted);
+ fprintf(stdout, " %s", quoted);
current_len += len;
}
- fwrite(buf, len, 1, stdout);
/*
* If verbose is set, then print out what this file includes.