summaryrefslogtreecommitdiffstats
path: root/Source/cmList.h
diff options
context:
space:
mode:
authorNicolas van Kempen <nvankemp@gmail.com>2023-07-03 21:05:01 (GMT)
committerNicolas van Kempen <nvankemp@gmail.com>2023-07-06 15:23:58 (GMT)
commita6e8811cf0d0b9dbb09c984d427e651eb29d9faf (patch)
treeab300bd57f363bf63c4a62d03ea7cc6cc97ace8c /Source/cmList.h
parentfbea5d9f9945363f35aa16c3edcf0924e3dc4686 (diff)
downloadCMake-a6e8811cf0d0b9dbb09c984d427e651eb29d9faf.zip
CMake-a6e8811cf0d0b9dbb09c984d427e651eb29d9faf.tar.gz
CMake-a6e8811cf0d0b9dbb09c984d427e651eb29d9faf.tar.bz2
cmList: Fix performance regression in Join / to_string
Refactoring in commit 45f17e5a85 (cmList: Add container conversion to string, 2023-06-20) accidentally introduced unnecessary string copies and allocations. Remove unnecessary copies.
Diffstat (limited to 'Source/cmList.h')
-rw-r--r--Source/cmList.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/cmList.h b/Source/cmList.h
index 9ee4a46..dc5850a 100644
--- a/Source/cmList.h
+++ b/Source/cmList.h
@@ -1211,13 +1211,12 @@ private:
const auto sep = std::string{ glue };
- return std::accumulate(
- std::next(std::begin(r)), std::end(r), cmList::ToString(*std::begin(r)),
- [&sep](std::string const& a,
- typename std::iterator_traits<decltype(std::begin(
- r))>::value_type const& b) -> std::string {
- return a + sep + cmList::ToString(b);
- });
+ std::string joined = cmList::ToString(*std::begin(r));
+ for (auto it = std::next(std::begin(r)); it != std::end(r); ++it) {
+ joined += sep + cmList::ToString(*it);
+ }
+
+ return joined;
}
container_type Values;