From 66c867395fa7f64e489896a9aee2129e4c716a88 Mon Sep 17 00:00:00 2001 From: Kamil Monicz Date: Fri, 19 Dec 2025 01:03:30 +0000 Subject: [PATCH] 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. --- src/libstore/derivations.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index a4cdcb17a..76539e951 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -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 buffer;