diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2017-05-18 22:10:04 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2017-05-18 22:10:04 +0000 |
commit | 29717eb02920eda35c810b444f7fa7b190155170 (patch) | |
tree | 2c17a270ead05e55dd91227e64771ab0b2f1f513 /bin/sh/output.c | |
parent | de29cd0869e37df15a49283781c378181cdd0c93 (diff) | |
download | src-29717eb02920eda35c810b444f7fa7b190155170.tar.gz src-29717eb02920eda35c810b444f7fa7b190155170.zip |
sh: Keep output buffer across builtins.
Allocating and deallocating repeatedly the 1024-byte buffer for stdout from
builtins costs CPU time for little or no benefit.
A simple loop containing builtins that write to a file descriptor, such as
i=0; while [ "$i" -lt 1000000 ]; do printf .; i=$((i+1)); done >/dev/null
is over 10% faster in a simple benchmark on an amd64 virtual machine.
Notes
Notes:
svn path=/head/; revision=318502
Diffstat (limited to 'bin/sh/output.c')
-rw-r--r-- | bin/sh/output.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/bin/sh/output.c b/bin/sh/output.c index c3458272785e..ced01d246a1c 100644 --- a/bin/sh/output.c +++ b/bin/sh/output.c @@ -254,14 +254,7 @@ flushout(struct output *dest) void freestdout(void) { - INTOFF; - if (output.buf) { - ckfree(output.buf); - output.nextc = NULL; - output.buf = NULL; - output.bufend = NULL; - } - INTON; + output.nextc = output.buf; } |