45 lines
1.3 KiB
Diff
45 lines
1.3 KiB
Diff
From 0144eeeb3d2412c6fad90fd7316dda1f6668d708 Mon Sep 17 00:00:00 2001
|
|
From: Assaf Gordon <assafgordon@gmail.com>
|
|
Date: Fri, 20 Jul 2018 19:24:12 -0600
|
|
Subject: [PATCH 04/61] sed: do not flush output stream unless in unbuffered
|
|
mode
|
|
|
|
Previously sed would explicitly flush the output after
|
|
every output line, except if the output was stdout in unbuffered mode.
|
|
|
|
In practice this was equivalent to forcing line-buffering, and was
|
|
espcially was noticable with "sed -i" (where the output is a temporary
|
|
file).
|
|
|
|
With this change, explicit flushing only happens with "sed -u",
|
|
regardless of the type of output file, making "sed -i" much faster.
|
|
This change also affect other write commands such as 'w'/'W' and 's///w'.
|
|
|
|
Reported by Vidar Holen <vidar@vidarholen.net> in
|
|
https://lists.gnu.org/r/bug-sed/2018-07/msg00014.html .
|
|
|
|
* NEWS: Mention this.
|
|
* sed/execute.c (flush_output): Never flush output unless in unbuffered
|
|
mode, regardless of which file it is.
|
|
---
|
|
NEWS | 7 +++++++
|
|
sed/execute.c | 2 +-
|
|
2 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/sed/execute.c b/sed/execute.c
|
|
index 7a4850f..1cc1d3f 100644
|
|
--- a/sed/execute.c
|
|
+++ b/sed/execute.c
|
|
@@ -415,7 +415,7 @@ output_missing_newline(struct output *outf)
|
|
static inline void
|
|
flush_output(FILE *fp)
|
|
{
|
|
- if (fp != stdout || unbuffered)
|
|
+ if (unbuffered)
|
|
ck_fflush(fp);
|
|
}
|
|
|
|
--
|
|
2.19.1
|
|
|