From 7c9db8f8139b945d4c55d9061e4ef122351b210d Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sat, 10 Dec 2016 14:42:49 +0100 Subject: clang-tidy: apply performance-unnecessary-value-param fixes --- Source/cmAlgorithms.h | 8 ++++---- Source/cmCTest.h | 2 +- Source/cmGeneratorExpressionEvaluator.h | 6 ++++-- Source/cmLocalGenerator.h | 2 +- Source/cmProcessOutput.cxx | 13 ++++++++----- Source/cmProcessOutput.h | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 22f69fa..7c683ad 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -242,7 +242,7 @@ std::string cmJoin(Range const& r, const char* delimiter) } template -std::string cmJoin(Range const& r, std::string delimiter) +std::string cmJoin(Range const& r, std::string const& delimiter) { return cmJoin(r, delimiter.c_str()); } @@ -344,13 +344,13 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r) } template -std::string cmWrap(std::string prefix, Range const& r, std::string suffix, - std::string sep) +std::string cmWrap(std::string const& prefix, Range const& r, + std::string const& suffix, std::string const& sep) { if (r.empty()) { return std::string(); } - return prefix + cmJoin(r, (suffix + sep + prefix).c_str()) + suffix; + return prefix + cmJoin(r, suffix + sep + prefix) + suffix; } template diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 8db2e5f..8fc646f 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -242,7 +242,7 @@ public: /** Used for parallel ctest job scheduling */ std::string GetScheduleType() { return this->ScheduleType; } - void SetScheduleType(std::string type) { this->ScheduleType = type; } + void SetScheduleType(std::string const& type) { this->ScheduleType = type; } /** The max output width */ int GetMaxTestNameWidth() const; diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 122e9cf..41bea9b 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -65,13 +65,15 @@ private: struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator { GeneratorExpressionContent(const char* startContent, size_t length); - void SetIdentifier(std::vector identifier) + void SetIdentifier( + std::vector const& identifier) { this->IdentifierChildren = identifier; } void SetParameters( - std::vector > parameters) + std::vector > const& + parameters) { this->ParamChildren = parameters; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index fdca78a..901ca35 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -148,7 +148,7 @@ public: void AppendDefines(std::set& defines, const char* defines_list) const; void AppendDefines(std::set& defines, - std::string defines_list) const + std::string const& defines_list) const { this->AppendDefines(defines, defines_list.c_str()); } diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx index 8b4d0e1..617e1ca 100644 --- a/Source/cmProcessOutput.cxx +++ b/Source/cmProcessOutput.cxx @@ -9,7 +9,8 @@ unsigned int cmProcessOutput::defaultCodepage = KWSYS_ENCODING_DEFAULT_CODEPAGE; #endif -cmProcessOutput::Encoding cmProcessOutput::FindEncoding(std::string name) +cmProcessOutput::Encoding cmProcessOutput::FindEncoding( + std::string const& name) { Encoding encoding = Auto; if (name == "UTF8") { @@ -54,9 +55,13 @@ cmProcessOutput::~cmProcessOutput() bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded, size_t id) { +#if !defined(_WIN32) + static_cast(id); + decoded.swap(raw); + return true; +#else bool success = true; decoded = raw; -#if defined(_WIN32) if (id > 0) { if (rawparts.size() < id) { rawparts.reserve(id); @@ -113,10 +118,8 @@ bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded, success = DoDecodeText(raw, decoded, NULL); } } -#else - static_cast(id); -#endif return success; +#endif } bool cmProcessOutput::DecodeText(const char* data, size_t length, diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h index 6046f57..d2e631f 100644 --- a/Source/cmProcessOutput.h +++ b/Source/cmProcessOutput.h @@ -32,7 +32,7 @@ public: * \param name a encoding name. * \return encoding enum value or Auto if \a name was not found. */ - static Encoding FindEncoding(std::string name); + static Encoding FindEncoding(std::string const& name); /// The code page that is used as internal encoding to which we will encode. static unsigned int defaultCodepage; -- cgit v0.12