mirror of
https://github.com/NixOS/nix.git
synced 2025-12-23 17:31:08 +01:00
Fix reserve pitfall in printString
Remove the per-call reserve() inside printString to avoid linear-growth reallocations when called in loops (e.g. printStrings). Derivation::unparse already pre-reserves a large buffer, so this remains efficient while preserving amortized growth behavior when the initial estimate is exceeded.
This commit is contained in:
parent
188cb798ad
commit
66c867395f
1 changed files with 0 additions and 1 deletions
|
|
@ -523,7 +523,6 @@ Derivation parseDerivation(
|
|||
*/
|
||||
static void printString(std::string & res, std::string_view s)
|
||||
{
|
||||
res.reserve(res.size() + s.size() * 2 + 2);
|
||||
res += '"';
|
||||
static constexpr auto chunkSize = 1024;
|
||||
std::array<char, 2 * chunkSize + 2> buffer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue