summaryrefslogtreecommitdiffstats
path: root/Source/cmAlgorithms.h
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2016-01-15 13:55:22 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-01-20 20:20:55 (GMT)
commit70788e92641c4cf4c3f20af607cc6e203203b420 (patch)
tree0ff1cc4d625217bc392e3be5daf875a7f68c58d0 /Source/cmAlgorithms.h
parentbd2384f593d0cf2c894ff781c4e5278fff2ac96c (diff)
downloadCMake-70788e92641c4cf4c3f20af607cc6e203203b420.zip
CMake-70788e92641c4cf4c3f20af607cc6e203203b420.tar.gz
CMake-70788e92641c4cf4c3f20af607cc6e203203b420.tar.bz2
Remove temporary allocations when calling cmHasLiteral{Suf,Pre}fix.
When the first argument passed is a std::string, we need to take it by const&, otherwise we copy the string and trigger a temporary allocation. This patch removes a few 10k temporary allocations when running the CMake daemon on the KDevelop build dir. This hotspot was found with heaptrack.
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r--Source/cmAlgorithms.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index ef607d2..54617f3 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -52,13 +52,13 @@ template<typename T, size_t N>
size_t cmArraySize(const T (&)[N]) { return N; }
template<typename T, size_t N>
-bool cmHasLiteralPrefix(T str1, const char (&str2)[N])
+bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralPrefixImpl(str1, str2, N - 1);
}
template<typename T, size_t N>
-bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
+bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
{
return cmHasLiteralSuffixImpl(str1, str2, N - 1);
}