mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-14 20:37:06 +00:00
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.
This commit is contained in:
parent
de29cd0869
commit
29717eb029
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318502
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue