aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-17 19:49:52 +0100
committerGitHub <noreply@github.com>2022-01-17 19:49:52 +0100
commitfc2443a67caa139fdfb0fa0fccf3d777d736ffe9 (patch)
tree8266100830cdde723f42e4332658a2ae464f7564 /src/libutil
parent008ddef4b08e9bee530a5a4c597c88b344089021 (diff)
parent72f42093e711db1ab43c920688bb5e59df33935d (diff)
Merge pull request #5812 from pennae/small-perf-improvements
improve parser performance a bit
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 9edd69c64..938808276 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -668,7 +668,9 @@ void writeFull(int fd, std::string_view s, bool allowInterrupts)
string drainFD(int fd, bool block, const size_t reserveSize)
{
- StringSink sink(reserveSize);
+ // the parser needs two extra bytes to append terminating characters, other users will
+ // not care very much about the extra memory.
+ StringSink sink(reserveSize + 2);
drainFD(fd, sink, block);
return std::move(*sink.s);
}