diff options
author | Guillaume Bouchard <guillaume.bouchard@tweag.io> | 2020-04-29 18:44:01 +0200 |
---|---|---|
committer | Guillaume Bouchard <guillaume.bouchard@tweag.io> | 2020-04-29 18:44:01 +0200 |
commit | 2e5be2a7495ac0b204454c74664e590a38d039d3 (patch) | |
tree | 3e2797c7a07bc4fd22559e1c83d3f0c84e2dc73a /src/libutil/util.hh | |
parent | 7afcb5af988eb0ce73c9916b809f8528dfb14c0f (diff) |
StringSink pre allocate
When used with `readFile`, we have a pretty good heuristic of the file
size, so `reserve` this in the `string`. This will save some allocation
/ copy when the string is growing.
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 32ef9a79a..1b263abcc 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -162,7 +162,7 @@ MakeError(EndOfFile, Error); /* Read a file descriptor until EOF occurs. */ -string drainFD(int fd, bool block = true); +string drainFD(int fd, bool block = true, const size_t reserveSize=0); void drainFD(int fd, Sink & sink, bool block = true); |