summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.h
diff options
context:
space:
mode:
authorOleksandr Koval <oleksandr.koval.dev@gmail.com>2020-09-03 20:25:37 (GMT)
committerOleksandr Koval <oleksandr.koval.dev@gmail.com>2020-09-03 20:25:37 (GMT)
commit38928ee3ee40179ec4ad295c72cf5aaa213f617e (patch)
tree3201e3a0c612cbf6dab0bf9ca44e87c688ae21ec /Source/cmStringAlgorithms.h
parentca5babfd7a1da8e32f927ad086fdd91c2b09853b (diff)
downloadCMake-38928ee3ee40179ec4ad295c72cf5aaa213f617e.zip
CMake-38928ee3ee40179ec4ad295c72cf5aaa213f617e.tar.gz
CMake-38928ee3ee40179ec4ad295c72cf5aaa213f617e.tar.bz2
cmStringAlgorithms: Add faster cmJoin overloads for strings
cmJoin() is often used with std::string ranges. Generic implementation uses std::ostringstream which is not optimal. With strings we can avoid operator<<() and make much faster implementation. Additional 'initial' argument is useful for cmStringCommand.cxx:HandleAppendCommand().
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r--Source/cmStringAlgorithms.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index 4b0090b..c82a949 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -81,6 +81,17 @@ std::string cmJoin(Range const& rng, cm::string_view separator)
return os.str();
}
+/**
+ * Faster overloads for std::string ranges.
+ * If @a initial is provided, it prepends the resulted string without
+ * @a separator between them.
+ */
+std::string cmJoin(std::vector<std::string> const& rng,
+ cm::string_view separator, cm::string_view initial = {});
+
+std::string cmJoin(cmStringRange const& rng, cm::string_view separator,
+ cm::string_view initial = {});
+
/** Extract tokens that are separated by any of the characters in @a sep. */
std::vector<std::string> cmTokenize(cm::string_view str, cm::string_view sep);