From 1bfede120aae0334a28ead8fa2733b8add7cb01d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Sep 2019 12:01:25 +0200 Subject: [PATCH] fs/Traits: call std::string::reserve() in BuildPathImpl() --- src/fs/Traits.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index ec44e408f..0e4a6c3c3 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -35,7 +35,10 @@ BuildPathImpl(typename Traits::const_pointer_type a, size_t a_size, if (b_size == 0) return typename Traits::string(a, a_size); - typename Traits::string result(a, a_size); + typename Traits::string result; + result.reserve(a_size + 1 + b_size); + + result.append(a, a_size); if (!Traits::IsSeparator(a[a_size - 1])) result.push_back(Traits::SEPARATOR);