From: Gunnar Beutner Date: Thu, 4 Jan 2018 07:54:18 +0000 (+0100) Subject: Apply clang-tidy fix 'modernize-pass-by-value' X-Git-Tag: v2.9.0~248^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=621eed3f139bd71f96e1d819b2201c1034f73edc;p=icinga2 Apply clang-tidy fix 'modernize-pass-by-value' --- diff --git a/lib/base/array.cpp b/lib/base/array.cpp index 202c9aee8..dad3d39bc 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -86,23 +86,11 @@ void Array::Set(SizeType index, Value&& value) * * @param value The value. */ -void Array::Add(const Value& value) +void Array::Add(Value value) { ObjectLock olock(this); - m_Data.push_back(value); -} - -/** - * Adds a value to the array. - * - * @param value The value. - */ -void Array::Add(Value&& value) -{ - ObjectLock olock(this); - - m_Data.emplace_back(std::move(value)); + m_Data.push_back(std::move(value)); } /** @@ -164,13 +152,13 @@ bool Array::Contains(const Value& value) const * @param index The index * @param value The value to add */ -void Array::Insert(SizeType index, const Value& value) +void Array::Insert(SizeType index, Value value) { ObjectLock olock(this); ASSERT(index <= m_Data.size()); - m_Data.insert(m_Data.begin() + index, value); + m_Data.insert(m_Data.begin() + index, std::move(value)); } /** @@ -314,12 +302,12 @@ void Array::SetFieldByName(const String& field, const Value& value, const DebugI Set(index, value); } -Array::Iterator icinga::begin(Array::Ptr x) +Array::Iterator icinga::begin(const Array::Ptr& x) { return x->Begin(); } -Array::Iterator icinga::end(Array::Ptr x) +Array::Iterator icinga::end(const Array::Ptr& x) { return x->End(); } diff --git a/lib/base/array.hpp b/lib/base/array.hpp index 716d09683..c14d95c5e 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -55,8 +55,7 @@ public: Value Get(SizeType index) const; void Set(SizeType index, const Value& value); void Set(SizeType index, Value&& value); - void Add(const Value& value); - void Add(Value&& value); + void Add(Value value); Iterator Begin(); Iterator End(); @@ -64,7 +63,7 @@ public: size_t GetLength() const; bool Contains(const Value& value) const; - void Insert(SizeType index, const Value& value); + void Insert(SizeType index, Value value); void Remove(SizeType index); void Remove(Iterator it); @@ -118,8 +117,8 @@ private: std::vector m_Data; /**< The data for the array. */ }; -Array::Iterator begin(Array::Ptr x); -Array::Iterator end(Array::Ptr x); +Array::Iterator begin(const Array::Ptr& x); +Array::Iterator end(const Array::Ptr& x); } diff --git a/lib/base/configtype.hpp b/lib/base/configtype.hpp index cf7f2b963..b81ed5e1c 100644 --- a/lib/base/configtype.hpp +++ b/lib/base/configtype.hpp @@ -54,7 +54,8 @@ public: { std::vector > objects = GetObjectsHelper(T::TypeInstance.get()); std::vector > result; - for (const auto& object : objects) { + result.reserve(objects.size()); +for (const auto& object : objects) { result.push_back(static_pointer_cast(object)); } return result; diff --git a/lib/base/configwriter.cpp b/lib/base/configwriter.cpp index 364e2518e..22fafde32 100644 --- a/lib/base/configwriter.cpp +++ b/lib/base/configwriter.cpp @@ -269,8 +269,8 @@ const std::vector& ConfigWriter::GetKeywords() return keywords; } -ConfigIdentifier::ConfigIdentifier(const String& identifier) - : m_Name(identifier) +ConfigIdentifier::ConfigIdentifier(String identifier) + : m_Name(std::move(identifier)) { } String ConfigIdentifier::GetName() const diff --git a/lib/base/configwriter.hpp b/lib/base/configwriter.hpp index 2649b8536..0ae4d92a5 100644 --- a/lib/base/configwriter.hpp +++ b/lib/base/configwriter.hpp @@ -38,7 +38,7 @@ class ConfigIdentifier final : public Object public: DECLARE_PTR_TYPEDEFS(ConfigIdentifier); - ConfigIdentifier(const String& name); + ConfigIdentifier(String name); String GetName() const; diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 76c9b2b4a..6726150c0 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -79,20 +79,7 @@ bool Dictionary::Get(const String& key, Value *result) const * @param key The key. * @param value The value. */ -void Dictionary::Set(const String& key, const Value& value) -{ - ObjectLock olock(this); - - m_Data[key] = value; -} - -/** - * Sets a value in the dictionary. - * - * @param key The key. - * @param value The value. - */ -void Dictionary::Set(const String& key, Value&& value) +void Dictionary::Set(const String& key, Value value) { ObjectLock olock(this); @@ -282,12 +269,12 @@ bool Dictionary::GetOwnField(const String& field, Value *result) const return Get(field, result); } -Dictionary::Iterator icinga::begin(Dictionary::Ptr x) +Dictionary::Iterator icinga::begin(const Dictionary::Ptr& x) { return x->Begin(); } -Dictionary::Iterator icinga::end(Dictionary::Ptr x) +Dictionary::Iterator icinga::end(const Dictionary::Ptr& x) { return x->End(); } diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index b2627b486..26c7c6a23 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -55,8 +55,7 @@ public: Value Get(const String& key) const; bool Get(const String& key, Value *result) const; - void Set(const String& key, const Value& value); - void Set(const String& key, Value&& value); + void Set(const String& key, Value value); bool Contains(const String& key) const; Iterator Begin(); @@ -90,8 +89,8 @@ private: std::map m_Data; /**< The data for the dictionary. */ }; -Dictionary::Iterator begin(Dictionary::Ptr x); -Dictionary::Iterator end(Dictionary::Ptr x); +Dictionary::Iterator begin(const Dictionary::Ptr& x); +Dictionary::Iterator end(const Dictionary::Ptr& x); } diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index 98bcd4241..ceddeecbe 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -260,7 +260,7 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta return result.str(); } -String icinga::DiagnosticInformation(boost::exception_ptr eptr, bool verbose) +String icinga::DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose) { StackTrace *pt = GetLastExceptionStack(); StackTrace stack; @@ -283,12 +283,12 @@ String icinga::DiagnosticInformation(boost::exception_ptr eptr, bool verbose) return boost::diagnostic_information(eptr); } -ScriptError::ScriptError(const String& message) - : m_Message(message), m_IncompleteExpr(false) +ScriptError::ScriptError(String message) + : m_Message(std::move(message)), m_IncompleteExpr(false) { } -ScriptError::ScriptError(const String& message, const DebugInfo& di, bool incompleteExpr) - : m_Message(message), m_DebugInfo(di), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false) +ScriptError::ScriptError(String message, DebugInfo di, bool incompleteExpr) + : m_Message(std::move(message)), m_DebugInfo(std::move(di)), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false) { } ScriptError::~ScriptError() throw() diff --git a/lib/base/exception.hpp b/lib/base/exception.hpp index 9c26c7468..208ac1d53 100644 --- a/lib/base/exception.hpp +++ b/lib/base/exception.hpp @@ -51,8 +51,8 @@ class user_error : virtual public std::exception, virtual public boost::exceptio class ScriptError : virtual public user_error { public: - ScriptError(const String& message); - ScriptError(const String& message, const DebugInfo& di, bool incompleteExpr = false); + ScriptError(String message); + ScriptError(String message, DebugInfo di, bool incompleteExpr = false); ~ScriptError() throw() override; const char *what(void) const throw() final; @@ -121,7 +121,7 @@ inline std::string to_string(const ContextTraceErrorInfo& e) } String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = nullptr, ContextTrace *context = nullptr); -String DiagnosticInformation(boost::exception_ptr eptr, bool verbose = true); +String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = true); class posix_error : virtual public std::exception, virtual public boost::exception { public: diff --git a/lib/base/function.cpp b/lib/base/function.cpp index 8fa90a3ca..13bf1d075 100644 --- a/lib/base/function.cpp +++ b/lib/base/function.cpp @@ -26,9 +26,9 @@ using namespace icinga; REGISTER_TYPE_WITH_PROTOTYPE(Function, Function::GetPrototype()); -Function::Function(const String& name, const Callback& function, const std::vector& args, +Function::Function(const String& name, Callback function, const std::vector& args, bool side_effect_free, bool deprecated) - : m_Callback(function) + : m_Callback(std::move(function)) { SetName(name, true); SetSideEffectFree(side_effect_free, true); diff --git a/lib/base/function.hpp b/lib/base/function.hpp index c9fa4d5d2..b607fea14 100644 --- a/lib/base/function.hpp +++ b/lib/base/function.hpp @@ -68,7 +68,7 @@ public: private: Callback m_Callback; - Function(const String& name, const Callback& function, const std::vector& args, + Function(const String& name, Callback function, const std::vector& args, bool side_effect_free, bool deprecated); }; diff --git a/lib/base/loader.hpp b/lib/base/loader.hpp index 5b07b187b..d54cada10 100644 --- a/lib/base/loader.hpp +++ b/lib/base/loader.hpp @@ -31,8 +31,8 @@ namespace icinga struct DeferredInitializer { public: - DeferredInitializer(const std::function& callback, int priority) - : m_Callback(callback), m_Priority(priority) + DeferredInitializer(std::function callback, int priority) + : m_Callback(std::move(callback)), m_Priority(priority) { } bool operator<(const DeferredInitializer& other) const diff --git a/lib/base/logger.cpp b/lib/base/logger.cpp index 1a915b966..227ed3694 100644 --- a/lib/base/logger.cpp +++ b/lib/base/logger.cpp @@ -194,14 +194,14 @@ void Logger::ValidateSeverity(const String& value, const ValidationUtils& utils) } } -Log::Log(LogSeverity severity, const String& facility, const String& message) - : m_Severity(severity), m_Facility(facility) +Log::Log(LogSeverity severity, String facility, const String& message) + : m_Severity(severity), m_Facility(std::move(facility)) { m_Buffer << message; } -Log::Log(LogSeverity severity, const String& facility) - : m_Severity(severity), m_Facility(facility) +Log::Log(LogSeverity severity, String facility) + : m_Severity(severity), m_Facility(std::move(facility)) { } /** diff --git a/lib/base/logger.hpp b/lib/base/logger.hpp index 96dfd8efa..1ed79b197 100644 --- a/lib/base/logger.hpp +++ b/lib/base/logger.hpp @@ -111,8 +111,8 @@ public: Log(const Log& other) = delete; Log& operator=(const Log& rhs) = delete; - Log(LogSeverity severity, const String& facility, const String& message); - Log(LogSeverity severity, const String& facility); + Log(LogSeverity severity, String facility, const String& message); + Log(LogSeverity severity, String facility); ~Log(); diff --git a/lib/base/networkstream.cpp b/lib/base/networkstream.cpp index d9e66e8cd..4752b3fbf 100644 --- a/lib/base/networkstream.cpp +++ b/lib/base/networkstream.cpp @@ -21,8 +21,8 @@ using namespace icinga; -NetworkStream::NetworkStream(const Socket::Ptr& socket) - : m_Socket(socket), m_Eof(false) +NetworkStream::NetworkStream(Socket::Ptr socket) + : m_Socket(std::move(socket)), m_Eof(false) { } void NetworkStream::Close() diff --git a/lib/base/networkstream.hpp b/lib/base/networkstream.hpp index 6b4f25bd6..edbd32f1c 100644 --- a/lib/base/networkstream.hpp +++ b/lib/base/networkstream.hpp @@ -37,7 +37,7 @@ class NetworkStream final : public Stream public: DECLARE_PTR_TYPEDEFS(NetworkStream); - NetworkStream(const Socket::Ptr& socket); + NetworkStream(Socket::Ptr socket); size_t Read(void *buffer, size_t count, bool allow_partial = false) override; void Write(const void *buffer, size_t count) override; diff --git a/lib/base/perfdatavalue.cpp b/lib/base/perfdatavalue.cpp index 17cb183bd..2c2829112 100644 --- a/lib/base/perfdatavalue.cpp +++ b/lib/base/perfdatavalue.cpp @@ -35,7 +35,7 @@ REGISTER_SCRIPTFUNCTION_NS(System, parse_performance_data, PerfdataValue::Parse, PerfdataValue::PerfdataValue() { } -PerfdataValue::PerfdataValue(String label, double value, bool counter, +PerfdataValue::PerfdataValue(const String& label, double value, bool counter, const String& unit, const Value& warn, const Value& crit, const Value& min, const Value& max) { diff --git a/lib/base/perfdatavalue.hpp b/lib/base/perfdatavalue.hpp index 35c88d106..c5128f8a7 100644 --- a/lib/base/perfdatavalue.hpp +++ b/lib/base/perfdatavalue.hpp @@ -38,7 +38,7 @@ public: PerfdataValue(); - PerfdataValue(String label, double value, bool counter = false, const String& unit = "", + PerfdataValue(const String& label, double value, bool counter = false, const String& unit = "", const Value& warn = Empty, const Value& crit = Empty, const Value& min = Empty, const Value& max = Empty); diff --git a/lib/base/primitivetype.cpp b/lib/base/primitivetype.cpp index 6be423d5e..9f1a6a3e8 100644 --- a/lib/base/primitivetype.cpp +++ b/lib/base/primitivetype.cpp @@ -22,8 +22,8 @@ using namespace icinga; -PrimitiveType::PrimitiveType(const String& name, const String& base, const ObjectFactory& factory) - : m_Name(name), m_Base(base), m_Factory(factory) +PrimitiveType::PrimitiveType(String name, String base, const ObjectFactory& factory) + : m_Name(std::move(name)), m_Base(std::move(base)), m_Factory(factory) { } String PrimitiveType::GetName() const diff --git a/lib/base/primitivetype.hpp b/lib/base/primitivetype.hpp index 562399dc7..45ae8411a 100644 --- a/lib/base/primitivetype.hpp +++ b/lib/base/primitivetype.hpp @@ -30,7 +30,7 @@ namespace icinga class PrimitiveType final : public Type { public: - PrimitiveType(const String& name, const String& base, const ObjectFactory& factory = ObjectFactory()); + PrimitiveType(String name, String base, const ObjectFactory& factory = ObjectFactory()); String GetName() const override; Type::Ptr GetBaseType() const override; diff --git a/lib/base/process.cpp b/lib/base/process.cpp index fef953dde..c9cced610 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -65,8 +65,8 @@ static pid_t l_ProcessControlPID; static boost::once_flag l_ProcessOnceFlag = BOOST_ONCE_INIT; static boost::once_flag l_SpawnHelperOnceFlag = BOOST_ONCE_INIT; -Process::Process(const Process::Arguments& arguments, const Dictionary::Ptr& extraEnvironment) - : m_Arguments(arguments), m_ExtraEnvironment(extraEnvironment), m_Timeout(600), m_AdjustPriority(false) +Process::Process(Process::Arguments arguments, Dictionary::Ptr extraEnvironment) + : m_Arguments(std::move(arguments)), m_ExtraEnvironment(std::move(extraEnvironment)), m_Timeout(600), m_AdjustPriority(false) #ifdef _WIN32 , m_ReadPending(false), m_ReadFailed(false), m_Overlapped() #endif /* _WIN32 */ diff --git a/lib/base/process.hpp b/lib/base/process.hpp index 6e62f1df7..b5d9db4e0 100644 --- a/lib/base/process.hpp +++ b/lib/base/process.hpp @@ -66,7 +66,7 @@ public: static const std::deque::size_type MaxTasksPerThread = 512; - Process(const Arguments& arguments, const Dictionary::Ptr& extraEnvironment = nullptr); + Process(Arguments arguments, Dictionary::Ptr extraEnvironment = nullptr); ~Process() override; void SetTimeout(double timeout); diff --git a/lib/base/scriptframe.cpp b/lib/base/scriptframe.cpp index 9ff9f0462..65597a783 100644 --- a/lib/base/scriptframe.cpp +++ b/lib/base/scriptframe.cpp @@ -46,8 +46,8 @@ ScriptFrame::ScriptFrame(bool allocLocals) InitializeFrame(); } -ScriptFrame::ScriptFrame(bool allocLocals, const Value& self) - : Locals(allocLocals ? new Dictionary() : nullptr), Self(self), Sandboxed(false), Depth(0) +ScriptFrame::ScriptFrame(bool allocLocals, Value self) + : Locals(allocLocals ? new Dictionary() : nullptr), Self(std::move(self)), Sandboxed(false), Depth(0) { InitializeFrame(); } diff --git a/lib/base/scriptframe.hpp b/lib/base/scriptframe.hpp index 54cb188c3..16a6592f5 100644 --- a/lib/base/scriptframe.hpp +++ b/lib/base/scriptframe.hpp @@ -37,7 +37,7 @@ struct ScriptFrame int Depth; ScriptFrame(bool allocLocals); - ScriptFrame(bool allocLocals, const Value& self); + ScriptFrame(bool allocLocals, Value self); ~ScriptFrame(); void IncreaseStackDepth(); diff --git a/lib/base/string.cpp b/lib/base/string.cpp index 675f97a60..998a73ceb 100644 --- a/lib/base/string.cpp +++ b/lib/base/string.cpp @@ -39,11 +39,7 @@ String::String(const char *data) : m_Data(data) { } -String::String(const std::string& data) - : m_Data(data) -{ } - -String::String(std::string&& data) +String::String(std::string data) : m_Data(std::move(data)) { } diff --git a/lib/base/string.hpp b/lib/base/string.hpp index b60eb2c98..d8a8d7626 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -60,8 +60,7 @@ public: String(); String(const char *data); - String(const std::string& data); - String(std::string&& data); + String(std::string data); String(String::SizeType n, char c); String(const String& other); String(String&& other); diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index c46944847..9225fd6d2 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -502,7 +502,7 @@ incomplete: } void ConsoleCommand::ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut, boost::exception_ptr& eptrOut) + bool& ready, const boost::exception_ptr& eptr, const Value& result, Value& resultOut, boost::exception_ptr& eptrOut) { if (eptr) { try { @@ -526,7 +526,7 @@ void ConsoleCommand::ExecuteScriptCompletionHandler(boost::mutex& mutex, boost:: } void ConsoleCommand::AutocompleteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, boost::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut) + bool& ready, const boost::exception_ptr& eptr, const Array::Ptr& result, Array::Ptr& resultOut) { if (eptr) { try { diff --git a/lib/cli/consolecommand.hpp b/lib/cli/consolecommand.hpp index 6180c58a9..9369080c4 100644 --- a/lib/cli/consolecommand.hpp +++ b/lib/cli/consolecommand.hpp @@ -55,10 +55,10 @@ private: mutable boost::condition_variable m_CV; static void ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut, + bool& ready, const boost::exception_ptr& eptr, const Value& result, Value& resultOut, boost::exception_ptr& eptrOut); static void AutocompleteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv, - bool& ready, boost::exception_ptr eptr, const Array::Ptr& result, Array::Ptr& resultOut); + bool& ready, const boost::exception_ptr& eptr, const Array::Ptr& result, Array::Ptr& resultOut); #ifdef HAVE_EDITLINE static char *ConsoleCompleteHelper(const char *word, int state); diff --git a/lib/cli/troubleshootcommand.cpp b/lib/cli/troubleshootcommand.cpp index 2649058c8..e86454225 100644 --- a/lib/cli/troubleshootcommand.cpp +++ b/lib/cli/troubleshootcommand.cpp @@ -324,9 +324,9 @@ bool TroubleshootCommand::CheckFeatures(InfoLog& log) return false; } - for (const String feature : disabled_features) + for (const String& feature : disabled_features) features->Set(feature, false); - for (const String feature : enabled_features) + for (const String& feature : enabled_features) features->Set(feature, true); InfoLogLine(log) diff --git a/lib/config/activationcontext.cpp b/lib/config/activationcontext.cpp index 843dec092..c22f41caf 100644 --- a/lib/config/activationcontext.cpp +++ b/lib/config/activationcontext.cpp @@ -57,8 +57,8 @@ ActivationContext::Ptr ActivationContext::GetCurrentContext() return astack.top(); } -ActivationScope::ActivationScope(const ActivationContext::Ptr& context) - : m_Context(context) +ActivationScope::ActivationScope(ActivationContext::Ptr context) + : m_Context(std::move(context)) { if (!m_Context) m_Context = new ActivationContext(); diff --git a/lib/config/activationcontext.hpp b/lib/config/activationcontext.hpp index 4040a8d3d..c5a275631 100644 --- a/lib/config/activationcontext.hpp +++ b/lib/config/activationcontext.hpp @@ -49,7 +49,7 @@ private: class ActivationScope { public: - ActivationScope(const ActivationContext::Ptr& context = nullptr); + ActivationScope(ActivationContext::Ptr context = nullptr); ~ActivationScope(); ActivationContext::Ptr GetContext() const; diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index 4ad291330..c8f012e23 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -26,11 +26,11 @@ using namespace icinga; ApplyRule::RuleMap ApplyRule::m_Rules; ApplyRule::TypeMap ApplyRule::m_Types; -ApplyRule::ApplyRule(const String& targetType, const String& name, const std::shared_ptr& expression, - const std::shared_ptr& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr& fterm, - bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope) - : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar), - m_FVVar(fvvar), m_FTerm(fterm), m_IgnoreOnError(ignoreOnError), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false) +ApplyRule::ApplyRule(String targetType, String name, std::shared_ptr expression, + std::shared_ptr filter, String package, String fkvar, String fvvar, std::shared_ptr fterm, + bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope) + : m_TargetType(std::move(targetType)), m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), + m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_DebugInfo(std::move(di)), m_Scope(std::move(scope)), m_HasMatches(false) { } String ApplyRule::GetTargetType() const diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 1d06598c7..91623df75 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -81,9 +81,9 @@ private: static TypeMap m_Types; static RuleMap m_Rules; - ApplyRule(const String& targetType, const String& name, const std::shared_ptr& expression, - const std::shared_ptr& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr& fterm, - bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); + ApplyRule(String targetType, String name, std::shared_ptr expression, + std::shared_ptr filter, String package, String fkvar, String fvvar, std::shared_ptr fterm, + bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope); }; } diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index 02730bc32..f8b754bb9 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -40,10 +40,10 @@ std::map > ConfigCompiler::m_ZoneDirs; * @param input Input stream for the configuration file. * @param zone The zone. */ -ConfigCompiler::ConfigCompiler(const String& path, std::istream *input, - const String& zone, const String& package) - : m_Path(path), m_Input(input), m_Zone(zone), m_Package(package), - m_Eof(false), m_OpenBraces(0) +ConfigCompiler::ConfigCompiler(String path, std::istream *input, + String zone, String package) + : m_Path(std::move(path)), m_Input(input), m_Zone(std::move(zone)), + m_Package(std::move(package)), m_Eof(false), m_OpenBraces(0) { InitializeScanner(); } @@ -339,7 +339,8 @@ bool ConfigCompiler::HasZoneConfigAuthority(const String& zoneName) if (!empty) { std::vector paths; - for (const ZoneFragment& zf : zoneDirs) { + paths.reserve(zoneDirs.size()); +for (const ZoneFragment& zf : zoneDirs) { paths.push_back(zf.Path); } diff --git a/lib/config/configcompiler.hpp b/lib/config/configcompiler.hpp index 3b7b1ae97..d4a03681e 100644 --- a/lib/config/configcompiler.hpp +++ b/lib/config/configcompiler.hpp @@ -86,8 +86,8 @@ struct ZoneFragment class ConfigCompiler { public: - explicit ConfigCompiler(const String& path, std::istream *input, - const String& zone = String(), const String& package = String()); + explicit ConfigCompiler(String path, std::istream *input, + String zone = String(), String package = String()); virtual ~ConfigCompiler(); std::unique_ptr Compile(); diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 20508c94c..6b30bc094 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -59,16 +59,16 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, run_with_activation_context, &ConfigItem::R * @param exprl Expression list for the item. * @param debuginfo Debug information. */ -ConfigItem::ConfigItem(const Type::Ptr& type, const String& name, - bool abstract, const std::shared_ptr& exprl, - const std::shared_ptr& filter, bool defaultTmpl, bool ignoreOnError, - const DebugInfo& debuginfo, const Dictionary::Ptr& scope, - const String& zone, const String& package) - : m_Type(type), m_Name(name), m_Abstract(abstract), - m_Expression(exprl), m_Filter(filter), +ConfigItem::ConfigItem(Type::Ptr type, String name, + bool abstract, std::shared_ptr exprl, + std::shared_ptr filter, bool defaultTmpl, bool ignoreOnError, + DebugInfo debuginfo, Dictionary::Ptr scope, + String zone, String package) + : m_Type(std::move(type)), m_Name(std::move(name)), m_Abstract(abstract), + m_Expression(std::move(exprl)), m_Filter(std::move(filter)), m_DefaultTmpl(defaultTmpl), m_IgnoreOnError(ignoreOnError), - m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone), - m_Package(package) + m_DebugInfo(std::move(debuginfo)), m_Scope(std::move(scope)), m_Zone(std::move(zone)), + m_Package(std::move(package)) { } diff --git a/lib/config/configitem.hpp b/lib/config/configitem.hpp index 30d28c572..f560fa64d 100644 --- a/lib/config/configitem.hpp +++ b/lib/config/configitem.hpp @@ -40,12 +40,12 @@ class ConfigItem final : public Object { public: DECLARE_PTR_TYPEDEFS(ConfigItem); - ConfigItem(const Type::Ptr& type, const String& name, bool abstract, - const std::shared_ptr& exprl, - const std::shared_ptr& filter, - bool defaultTmpl, bool ignoreOnError, const DebugInfo& debuginfo, - const Dictionary::Ptr& scope, const String& zone, - const String& package); + ConfigItem(Type::Ptr type, String name, bool abstract, + std::shared_ptr exprl, + std::shared_ptr filter, + bool defaultTmpl, bool ignoreOnError, DebugInfo debuginfo, + Dictionary::Ptr scope, String zone, + String package); Type::Ptr GetType() const; String GetName() const; diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 9692655a2..bb7fe2248 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -101,8 +101,8 @@ void DictExpression::MakeInline() m_Inline = true; } -LiteralExpression::LiteralExpression(const Value& value) - : m_Value(value) +LiteralExpression::LiteralExpression(Value value) + : m_Value(std::move(value)) { } ExpressionResult LiteralExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 7dc0876a3..8c2882cdd 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -36,8 +36,8 @@ namespace icinga struct DebugHint { public: - DebugHint(const Dictionary::Ptr& hints = nullptr) - : m_Hints(hints) + DebugHint(Dictionary::Ptr hints = nullptr) + : m_Hints(std::move(hints)) { } DebugHint(Dictionary::Ptr&& hints) @@ -154,8 +154,8 @@ struct ExpressionResult { public: template - ExpressionResult(const T& value, ExpressionResultCode code = ResultOK) - : m_Value(value), m_Code(code) + ExpressionResult(T value, ExpressionResultCode code = ResultOK) + : m_Value(std::move(value)), m_Code(code) { } operator const Value&() const @@ -220,8 +220,8 @@ std::unique_ptr MakeIndexer(ScopeSpecifier scopeSpec, const String& class OwnedExpression final : public Expression { public: - OwnedExpression(const std::shared_ptr& expression) - : m_Expression(expression) + OwnedExpression(std::shared_ptr expression) + : m_Expression(std::move(expression)) { } protected: @@ -242,7 +242,7 @@ private: class LiteralExpression final : public Expression { public: - LiteralExpression(const Value& value = Value()); + LiteralExpression(Value value = Value()); const Value& GetValue() const { @@ -269,8 +269,8 @@ inline std::unique_ptr MakeLiteral(const Value& literal = Val class DebuggableExpression : public Expression { public: - DebuggableExpression(const DebugInfo& debugInfo = DebugInfo()) - : m_DebugInfo(debugInfo) + DebuggableExpression(DebugInfo debugInfo = DebugInfo()) + : m_DebugInfo(std::move(debugInfo)) { } protected: @@ -305,8 +305,8 @@ protected: class VariableExpression final : public DebuggableExpression { public: - VariableExpression(const String& variable, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_Variable(variable) + VariableExpression(String variable, const DebugInfo& debugInfo = DebugInfo()) + : DebuggableExpression(debugInfo), m_Variable(std::move(variable)) { } String GetVariable() const @@ -768,9 +768,9 @@ protected: class FunctionExpression final : public DebuggableExpression { public: - FunctionExpression(const String& name, const std::vector& args, + FunctionExpression(String name, std::vector args, std::map >&& closedVars, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression)) + : DebuggableExpression(debugInfo), m_Name(std::move(name)), m_Args(std::move(args)), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression)) { } protected: @@ -786,12 +786,12 @@ private: class ApplyExpression final : public DebuggableExpression { public: - ApplyExpression(const String& type, const String& target, std::unique_ptr name, - std::unique_ptr filter, const String& package, const String& fkvar, const String& fvvar, + ApplyExpression(String type, String target, std::unique_ptr name, + std::unique_ptr filter, String package, String fkvar, String fvvar, std::unique_ptr fterm, std::map >&& closedVars, bool ignoreOnError, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_Type(type), m_Target(target), - m_Name(std::move(name)), m_Filter(std::move(filter)), m_Package(package), m_FKVar(fkvar), m_FVVar(fvvar), + : DebuggableExpression(debugInfo), m_Type(std::move(type)), m_Target(std::move(target)), + m_Name(std::move(name)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression)) { } @@ -817,10 +817,10 @@ class ObjectExpression final : public DebuggableExpression { public: ObjectExpression(bool abstract, std::unique_ptr type, std::unique_ptr name, std::unique_ptr filter, - const String& zone, const String& package, std::map >&& closedVars, + String zone, String package, std::map >&& closedVars, bool defaultTmpl, bool ignoreOnError, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) : DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(std::move(type)), - m_Name(std::move(name)), m_Filter(std::move(filter)), m_Zone(zone), m_Package(package), m_DefaultTmpl(defaultTmpl), + m_Name(std::move(name)), m_Filter(std::move(filter)), m_Zone(std::move(zone)), m_Package(std::move(package)), m_DefaultTmpl(defaultTmpl), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression)) { } @@ -843,8 +843,8 @@ private: class ForExpression final : public DebuggableExpression { public: - ForExpression(const String& fkvar, const String& fvvar, std::unique_ptr value, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_FKVar(fkvar), m_FVVar(fvvar), m_Value(std::move(value)), m_Expression(std::move(expression)) + ForExpression(String fkvar, String fvvar, std::unique_ptr value, std::unique_ptr expression, const DebugInfo& debugInfo = DebugInfo()) + : DebuggableExpression(debugInfo), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)), m_Value(std::move(value)), m_Expression(std::move(expression)) { } protected: @@ -878,10 +878,10 @@ enum IncludeType class IncludeExpression final : public DebuggableExpression { public: - IncludeExpression(const String& relativeBase, std::unique_ptr path, std::unique_ptr pattern, std::unique_ptr name, - IncludeType type, bool searchIncludes, const String& zone, const String& package, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_RelativeBase(relativeBase), m_Path(std::move(path)), m_Pattern(std::move(pattern)), - m_Name(std::move(name)), m_Type(type), m_SearchIncludes(searchIncludes), m_Zone(zone), m_Package(package) + IncludeExpression(String relativeBase, std::unique_ptr path, std::unique_ptr pattern, std::unique_ptr name, + IncludeType type, bool searchIncludes, String zone, String package, const DebugInfo& debugInfo = DebugInfo()) + : DebuggableExpression(debugInfo), m_RelativeBase(std::move(relativeBase)), m_Path(std::move(path)), m_Pattern(std::move(pattern)), + m_Name(std::move(name)), m_Type(type), m_SearchIncludes(searchIncludes), m_Zone(std::move(zone)), m_Package(std::move(package)) { } protected: diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index abe1ddfed..ab2ba3e2b 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -1247,7 +1247,7 @@ void DbEvents::AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkabl AddLogHistory(checkable, msgbuf.str(), LogEntryTypeInfoMessage); } -void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type) +void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, const String& buffer, LogEntryType type) { Log(LogDebug, "DbEvents") << "add log entry history for '" << checkable->GetName() << "'"; diff --git a/lib/db_ido/dbevents.hpp b/lib/db_ido/dbevents.hpp index b651dd600..db52ccf1b 100644 --- a/lib/db_ido/dbevents.hpp +++ b/lib/db_ido/dbevents.hpp @@ -66,7 +66,7 @@ public: static void AddDowntimes(const Checkable::Ptr& checkable); static void RemoveDowntimes(const Checkable::Ptr& checkable); - static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type); + static void AddLogHistory(const Checkable::Ptr& checkable, const String& buffer, LogEntryType type); /* Status */ static void NextCheckUpdatedHandler(const Checkable::Ptr& checkable); diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp index d781756c4..7a7fa92ae 100644 --- a/lib/db_ido/dbobject.cpp +++ b/lib/db_ido/dbobject.cpp @@ -45,8 +45,8 @@ boost::signals2::signal&)> DbObject::OnMultiple INITIALIZE_ONCE(&DbObject::StaticInitialize); -DbObject::DbObject(const intrusive_ptr& type, const String& name1, const String& name2) - : m_Name1(name1), m_Name2(name2), m_Type(type), m_LastConfigUpdate(0), m_LastStatusUpdate(0) +DbObject::DbObject(intrusive_ptr type, String name1, String name2) + : m_Name1(std::move(name1)), m_Name2(std::move(name2)), m_Type(std::move(type)), m_LastConfigUpdate(0), m_LastStatusUpdate(0) { } void DbObject::StaticInitialize() diff --git a/lib/db_ido/dbobject.hpp b/lib/db_ido/dbobject.hpp index 16f23d49c..a90170d74 100644 --- a/lib/db_ido/dbobject.hpp +++ b/lib/db_ido/dbobject.hpp @@ -93,7 +93,7 @@ public: virtual String CalculateConfigHash(const Dictionary::Ptr& configFields) const; protected: - DbObject(const intrusive_ptr& type, const String& name1, const String& name2); + DbObject(intrusive_ptr type, String name1, String name2); virtual void OnConfigUpdateHeavy(); virtual void OnConfigUpdateLight(); diff --git a/lib/db_ido/dbtype.cpp b/lib/db_ido/dbtype.cpp index 1dc1e3301..65b56896b 100644 --- a/lib/db_ido/dbtype.cpp +++ b/lib/db_ido/dbtype.cpp @@ -25,8 +25,8 @@ using namespace icinga; -DbType::DbType(const String& name, const String& table, long tid, const String& idcolumn, const DbType::ObjectFactory& factory) - : m_Name(name), m_Table(table), m_TypeID(tid), m_IDColumn(idcolumn), m_ObjectFactory(factory) +DbType::DbType(String name, String table, long tid, String idcolumn, DbType::ObjectFactory factory) + : m_Name(std::move(name)), m_Table(std::move(table)), m_TypeID(tid), m_IDColumn(std::move(idcolumn)), m_ObjectFactory(std::move(factory)) { } String DbType::GetName() const diff --git a/lib/db_ido/dbtype.hpp b/lib/db_ido/dbtype.hpp index cc1e9b3d2..ad6f3f957 100644 --- a/lib/db_ido/dbtype.hpp +++ b/lib/db_ido/dbtype.hpp @@ -45,7 +45,7 @@ public: typedef std::map TypeMap; typedef std::map, intrusive_ptr > ObjectMap; - DbType(const String& name, const String& table, long tid, const String& idcolumn, const ObjectFactory& factory); + DbType(String name, String table, long tid, String idcolumn, ObjectFactory factory); String GetName() const; String GetTable() const; diff --git a/lib/db_ido/dbvalue.cpp b/lib/db_ido/dbvalue.cpp index 2c4a2750f..a626e59fe 100644 --- a/lib/db_ido/dbvalue.cpp +++ b/lib/db_ido/dbvalue.cpp @@ -21,8 +21,8 @@ using namespace icinga; -DbValue::DbValue(DbValueType type, const Value& value) - : m_Type(type), m_Value(value) +DbValue::DbValue(DbValueType type, Value value) + : m_Type(type), m_Value(std::move(value)) { } Value DbValue::FromTimestamp(const Value& ts) diff --git a/lib/db_ido/dbvalue.hpp b/lib/db_ido/dbvalue.hpp index aad636ac6..fcb985409 100644 --- a/lib/db_ido/dbvalue.hpp +++ b/lib/db_ido/dbvalue.hpp @@ -44,7 +44,7 @@ struct DbValue final : public Object public: DECLARE_PTR_TYPEDEFS(DbValue); - DbValue(DbValueType type, const Value& value); + DbValue(DbValueType type, Value value); static Value FromTimestamp(const Value& ts); static Value FromTimestampNow(); diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 481c08d04..af337e660 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -31,6 +31,7 @@ #include "base/exception.hpp" #include "base/statsfunction.hpp" #include +#include using namespace icinga; @@ -132,7 +133,7 @@ void IdoMysqlConnection::ExceptionHandler(boost::exception_ptr exp) Log(LogCritical, "IdoMysqlConnection", "Exception during database operation: Verify that your database is operational!"); Log(LogDebug, "IdoMysqlConnection") - << "Exception during database operation: " << DiagnosticInformation(exp); + << "Exception during database operation: " << DiagnosticInformation(std::move(exp)); if (GetConnected()) { m_Mysql->close(&m_Connection); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index b89bf4d20..2a8962853 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -32,6 +32,7 @@ #include "base/context.hpp" #include "base/statsfunction.hpp" #include +#include using namespace icinga; @@ -131,7 +132,7 @@ void IdoPgsqlConnection::ExceptionHandler(boost::exception_ptr exp) Log(LogWarning, "IdoPgsqlConnection", "Exception during database operation: Verify that your database is operational!"); Log(LogDebug, "IdoPgsqlConnection") - << "Exception during database operation: " << DiagnosticInformation(exp); + << "Exception during database operation: " << DiagnosticInformation(std::move(exp)); if (GetConnected()) { m_Pgsql->finish(m_Connection); diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 8e5388ac1..3139e0d52 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -55,7 +55,7 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command) return result; } -String CompatUtility::GetCommandNamePrefix(const Command::Ptr command) +String CompatUtility::GetCommandNamePrefix(const Command::Ptr& command) { if (!command) return Empty; @@ -71,7 +71,7 @@ String CompatUtility::GetCommandNamePrefix(const Command::Ptr command) return prefix; } -String CompatUtility::GetCommandName(const Command::Ptr command) +String CompatUtility::GetCommandName(const Command::Ptr& command) { if (!command) return Empty; diff --git a/lib/icinga/compatutility.hpp b/lib/icinga/compatutility.hpp index a0a96a0ce..5cfcbe7e3 100644 --- a/lib/icinga/compatutility.hpp +++ b/lib/icinga/compatutility.hpp @@ -41,7 +41,7 @@ class CompatUtility public: /* command */ static String GetCommandLine(const Command::Ptr& command); - static String GetCommandName(const Command::Ptr command); + static String GetCommandName(const Command::Ptr& command); /* host */ static int GetHostCurrentState(const Host::Ptr& host); @@ -122,7 +122,7 @@ public: private: CompatUtility(); - static String GetCommandNamePrefix(const Command::Ptr command); + static String GetCommandNamePrefix(const Command::Ptr& command); }; } diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp index 5b8b322f5..2b27eaaa8 100644 --- a/lib/icinga/scheduleddowntime.hpp +++ b/lib/icinga/scheduleddowntime.hpp @@ -23,7 +23,6 @@ #include "icinga/i2-icinga.hpp" #include "icinga/scheduleddowntime.thpp" #include "icinga/checkable.hpp" -#include namespace icinga { diff --git a/lib/icinga/service.hpp b/lib/icinga/service.hpp index dd7c54e1f..39952a2b1 100644 --- a/lib/icinga/service.hpp +++ b/lib/icinga/service.hpp @@ -24,7 +24,6 @@ #include "icinga/service.thpp" #include "icinga/macroresolver.hpp" #include "icinga/host.hpp" -#include #include using std::tie; diff --git a/lib/livestatus/attributefilter.cpp b/lib/livestatus/attributefilter.cpp index 58050d014..35ed40cf7 100644 --- a/lib/livestatus/attributefilter.cpp +++ b/lib/livestatus/attributefilter.cpp @@ -27,8 +27,8 @@ using namespace icinga; -AttributeFilter::AttributeFilter(const String& column, const String& op, const String& operand) - : m_Column(column), m_Operator(op), m_Operand(operand) +AttributeFilter::AttributeFilter(String column, String op, String operand) + : m_Column(std::move(column)), m_Operator(std::move(op)), m_Operand(std::move(operand)) { } bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row) diff --git a/lib/livestatus/attributefilter.hpp b/lib/livestatus/attributefilter.hpp index c3a607192..f8220eaad 100644 --- a/lib/livestatus/attributefilter.hpp +++ b/lib/livestatus/attributefilter.hpp @@ -35,7 +35,7 @@ class AttributeFilter final : public Filter public: DECLARE_PTR_TYPEDEFS(AttributeFilter); - AttributeFilter(const String& column, const String& op, const String& operand); + AttributeFilter(String column, String op, String operand); bool Apply(const Table::Ptr& table, const Value& row) override; diff --git a/lib/livestatus/avgaggregator.cpp b/lib/livestatus/avgaggregator.cpp index 0c9af05b6..592aadb1c 100644 --- a/lib/livestatus/avgaggregator.cpp +++ b/lib/livestatus/avgaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -AvgAggregator::AvgAggregator(const String& attr) - : m_AvgAttr(attr) +AvgAggregator::AvgAggregator(String attr) + : m_AvgAttr(std::move(attr)) { } AvgAggregatorState *AvgAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/avgaggregator.hpp b/lib/livestatus/avgaggregator.hpp index 592ac50d4..183ddb059 100644 --- a/lib/livestatus/avgaggregator.hpp +++ b/lib/livestatus/avgaggregator.hpp @@ -47,7 +47,7 @@ class AvgAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(AvgAggregator); - AvgAggregator(const String& attr); + AvgAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/column.cpp b/lib/livestatus/column.cpp index c4670f398..8cdd4eacf 100644 --- a/lib/livestatus/column.cpp +++ b/lib/livestatus/column.cpp @@ -21,8 +21,8 @@ using namespace icinga; -Column::Column(const ValueAccessor& valueAccessor, const ObjectAccessor& objectAccessor) - : m_ValueAccessor(valueAccessor), m_ObjectAccessor(objectAccessor) +Column::Column(ValueAccessor valueAccessor, ObjectAccessor objectAccessor) + : m_ValueAccessor(std::move(valueAccessor)), m_ObjectAccessor(std::move(objectAccessor)) { } Value Column::ExtractValue(const Value& urow, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject) const diff --git a/lib/livestatus/column.hpp b/lib/livestatus/column.hpp index 7a0ad1c69..4cc132ab7 100644 --- a/lib/livestatus/column.hpp +++ b/lib/livestatus/column.hpp @@ -40,7 +40,7 @@ public: typedef std::function ValueAccessor; typedef std::function ObjectAccessor; - Column(const ValueAccessor& valueAccessor, const ObjectAccessor& objectAccessor); + Column(ValueAccessor valueAccessor, ObjectAccessor objectAccessor); Value ExtractValue(const Value& urow, LivestatusGroupByType groupByType = LivestatusGroupByNone, const Object::Ptr& groupByObject = Empty) const; diff --git a/lib/livestatus/filter.hpp b/lib/livestatus/filter.hpp index 71270e741..2febc8db3 100644 --- a/lib/livestatus/filter.hpp +++ b/lib/livestatus/filter.hpp @@ -37,7 +37,7 @@ public: virtual bool Apply(const Table::Ptr& table, const Value& row) = 0; protected: - Filter(); + Filter() = default; }; } diff --git a/lib/livestatus/invavgaggregator.cpp b/lib/livestatus/invavgaggregator.cpp index 5e739a667..82ed69f70 100644 --- a/lib/livestatus/invavgaggregator.cpp +++ b/lib/livestatus/invavgaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -InvAvgAggregator::InvAvgAggregator(const String& attr) - : m_InvAvgAttr(attr) +InvAvgAggregator::InvAvgAggregator(String attr) + : m_InvAvgAttr(std::move(attr)) { } InvAvgAggregatorState *InvAvgAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/invavgaggregator.hpp b/lib/livestatus/invavgaggregator.hpp index 3bfb389d1..05a255da8 100644 --- a/lib/livestatus/invavgaggregator.hpp +++ b/lib/livestatus/invavgaggregator.hpp @@ -47,7 +47,7 @@ class InvAvgAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(InvAvgAggregator); - InvAvgAggregator(const String& attr); + InvAvgAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/invsumaggregator.cpp b/lib/livestatus/invsumaggregator.cpp index a1b3f25d3..dc6eac69c 100644 --- a/lib/livestatus/invsumaggregator.cpp +++ b/lib/livestatus/invsumaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -InvSumAggregator::InvSumAggregator(const String& attr) - : m_InvSumAttr(attr) +InvSumAggregator::InvSumAggregator(String attr) + : m_InvSumAttr(std::move(attr)) { } InvSumAggregatorState *InvSumAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/invsumaggregator.hpp b/lib/livestatus/invsumaggregator.hpp index 43804ac28..65b8d026d 100644 --- a/lib/livestatus/invsumaggregator.hpp +++ b/lib/livestatus/invsumaggregator.hpp @@ -46,7 +46,7 @@ class InvSumAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(InvSumAggregator); - InvSumAggregator(const String& attr); + InvSumAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/livestatusquery.cpp b/lib/livestatus/livestatusquery.cpp index 62b6016c4..ab33f8638 100644 --- a/lib/livestatus/livestatusquery.cpp +++ b/lib/livestatus/livestatusquery.cpp @@ -534,7 +534,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream) int index = 0; - for (const Aggregator::Ptr aggregator : m_Aggregators) { + for (const Aggregator::Ptr& aggregator : m_Aggregators) { aggregator->Apply(table, object.Row, &stats[index]); index++; } diff --git a/lib/livestatus/maxaggregator.cpp b/lib/livestatus/maxaggregator.cpp index 69c83103b..a2265430b 100644 --- a/lib/livestatus/maxaggregator.cpp +++ b/lib/livestatus/maxaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -MaxAggregator::MaxAggregator(const String& attr) - : m_MaxAttr(attr) +MaxAggregator::MaxAggregator(String attr) + : m_MaxAttr(std::move(attr)) { } MaxAggregatorState *MaxAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/maxaggregator.hpp b/lib/livestatus/maxaggregator.hpp index 9515c3d71..fd102d1f2 100644 --- a/lib/livestatus/maxaggregator.hpp +++ b/lib/livestatus/maxaggregator.hpp @@ -46,7 +46,7 @@ class MaxAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(MaxAggregator); - MaxAggregator(const String& attr); + MaxAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/minaggregator.cpp b/lib/livestatus/minaggregator.cpp index 5060ab071..bf4390230 100644 --- a/lib/livestatus/minaggregator.cpp +++ b/lib/livestatus/minaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -MinAggregator::MinAggregator(const String& attr) - : m_MinAttr(attr) +MinAggregator::MinAggregator(String attr) + : m_MinAttr(std::move(attr)) { } MinAggregatorState *MinAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/minaggregator.hpp b/lib/livestatus/minaggregator.hpp index a703474f1..b9560937d 100644 --- a/lib/livestatus/minaggregator.hpp +++ b/lib/livestatus/minaggregator.hpp @@ -47,7 +47,7 @@ class MinAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(MinAggregator); - MinAggregator(const String& attr); + MinAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/negatefilter.cpp b/lib/livestatus/negatefilter.cpp index 82d971ba0..8a8f341c6 100644 --- a/lib/livestatus/negatefilter.cpp +++ b/lib/livestatus/negatefilter.cpp @@ -21,8 +21,8 @@ using namespace icinga; -NegateFilter::NegateFilter(const Filter::Ptr& inner) - : m_Inner(inner) +NegateFilter::NegateFilter(Filter::Ptr inner) + : m_Inner(std::move(inner)) { } bool NegateFilter::Apply(const Table::Ptr& table, const Value& row) diff --git a/lib/livestatus/negatefilter.hpp b/lib/livestatus/negatefilter.hpp index f0744a11d..4a88f35e4 100644 --- a/lib/livestatus/negatefilter.hpp +++ b/lib/livestatus/negatefilter.hpp @@ -35,7 +35,7 @@ class NegateFilter final : public Filter public: DECLARE_PTR_TYPEDEFS(NegateFilter); - NegateFilter(const Filter::Ptr& inner); + NegateFilter(Filter::Ptr inner); bool Apply(const Table::Ptr& table, const Value& row) override; diff --git a/lib/livestatus/stdaggregator.cpp b/lib/livestatus/stdaggregator.cpp index d72500661..8d3876e02 100644 --- a/lib/livestatus/stdaggregator.cpp +++ b/lib/livestatus/stdaggregator.cpp @@ -22,8 +22,8 @@ using namespace icinga; -StdAggregator::StdAggregator(const String& attr) - : m_StdAttr(attr) +StdAggregator::StdAggregator(String attr) + : m_StdAttr(std::move(attr)) { } StdAggregatorState *StdAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/stdaggregator.hpp b/lib/livestatus/stdaggregator.hpp index baadf3165..75c4e3e86 100644 --- a/lib/livestatus/stdaggregator.hpp +++ b/lib/livestatus/stdaggregator.hpp @@ -48,7 +48,7 @@ class StdAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(StdAggregator); - StdAggregator(const String& attr); + StdAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/sumaggregator.cpp b/lib/livestatus/sumaggregator.cpp index 4aee38f77..50d124f05 100644 --- a/lib/livestatus/sumaggregator.cpp +++ b/lib/livestatus/sumaggregator.cpp @@ -21,8 +21,8 @@ using namespace icinga; -SumAggregator::SumAggregator(const String& attr) - : m_SumAttr(attr) +SumAggregator::SumAggregator(String attr) + : m_SumAttr(std::move(attr)) { } SumAggregatorState *SumAggregator::EnsureState(AggregatorState **state) diff --git a/lib/livestatus/sumaggregator.hpp b/lib/livestatus/sumaggregator.hpp index 9215899ea..b2359e642 100644 --- a/lib/livestatus/sumaggregator.hpp +++ b/lib/livestatus/sumaggregator.hpp @@ -46,7 +46,7 @@ class SumAggregator final : public Aggregator public: DECLARE_PTR_TYPEDEFS(SumAggregator); - SumAggregator(const String& attr); + SumAggregator(String attr); void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override; double GetResultAndFreeState(AggregatorState *state) const override; diff --git a/lib/livestatus/zonestable.cpp b/lib/livestatus/zonestable.cpp index 87d086ae0..f94c825ea 100644 --- a/lib/livestatus/zonestable.cpp +++ b/lib/livestatus/zonestable.cpp @@ -91,7 +91,7 @@ Value ZonesTable::EndpointsAccessor(const Value& row) Array::Ptr endpoint_names = new Array(); - for (const Endpoint::Ptr endpoint : endpoints) { + for (const Endpoint::Ptr& endpoint : endpoints) { endpoint_names->Add(endpoint->GetName()); } diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index 032e4feea..70a757a4f 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -109,7 +109,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResul double bytesSentPerSecond = 0; double bytesReceivedPerSecond = 0; - for (Endpoint::Ptr endpoint : endpoints) + for (const Endpoint::Ptr& endpoint : endpoints) { if (endpoint->GetLastMessageSent() > lastMessageSent) lastMessageSent = endpoint->GetLastMessageSent(); diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 3a99cf132..fdb0b0ce5 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -36,6 +36,7 @@ #include "base/statsfunction.hpp" #include #include +#include using namespace icinga; @@ -341,7 +342,7 @@ void ElasticsearchWriter::NotificationSentToAllUsersHandlerInternal(const Notifi Enqueue("notification", fields, ts); } -void ElasticsearchWriter::Enqueue(String type, const Dictionary::Ptr& fields, double ts) +void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fields, double ts) { /* Atomically buffer the data point. */ boost::mutex::scoped_lock lock(m_DataBufferMutex); @@ -575,7 +576,7 @@ void ElasticsearchWriter::ExceptionHandler(boost::exception_ptr exp) Log(LogCritical, "ElasticsearchWriter", "Exception during Elastic operation: Verify that your backend is operational!"); Log(LogDebug, "ElasticsearchWriter") - << "Exception during Elasticsearch operation: " << DiagnosticInformation(exp); + << "Exception during Elasticsearch operation: " << DiagnosticInformation(std::move(exp)); } String ElasticsearchWriter::FormatTimestamp(double ts) diff --git a/lib/perfdata/elasticsearchwriter.hpp b/lib/perfdata/elasticsearchwriter.hpp index 604ae757c..4779fefb2 100644 --- a/lib/perfdata/elasticsearchwriter.hpp +++ b/lib/perfdata/elasticsearchwriter.hpp @@ -66,7 +66,7 @@ private: const Checkable::Ptr& checkable, const std::set& users, NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text); - void Enqueue(String type, const Dictionary::Ptr& fields, double ts); + void Enqueue(const String& type, const Dictionary::Ptr& fields, double ts); Stream::Ptr Connect(); void AssertOnWorkQueue(); diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index 16fd77d94..490672f33 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -38,6 +38,7 @@ #include "base/json.hpp" #include "base/statsfunction.hpp" #include +#include using namespace icinga; @@ -122,7 +123,7 @@ void GelfWriter::ExceptionHandler(boost::exception_ptr exp) Log(LogCritical, "GelfWriter", "Exception during Graylog Gelf operation: Verify that your backend is operational!"); Log(LogDebug, "GelfWriter") - << "Exception during Graylog Gelf operation: " << DiagnosticInformation(exp); + << "Exception during Graylog Gelf operation: " << DiagnosticInformation(std::move(exp)); if (GetConnected()) { m_Stream->Close(); diff --git a/lib/perfdata/graphitewriter.cpp b/lib/perfdata/graphitewriter.cpp index c4721a778..bb5f20bda 100644 --- a/lib/perfdata/graphitewriter.cpp +++ b/lib/perfdata/graphitewriter.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace icinga; @@ -119,7 +120,7 @@ void GraphiteWriter::ExceptionHandler(boost::exception_ptr exp) Log(LogCritical, "GraphiteWriter", "Exception during Graphite operation: Verify that your backend is operational!"); Log(LogDebug, "GraphiteWriter") - << "Exception during Graphite operation: " << DiagnosticInformation(exp); + << "Exception during Graphite operation: " << DiagnosticInformation(std::move(exp)); if (GetConnected()) { m_Stream->Close(); diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index 6bd99d659..5c4913818 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -46,6 +46,7 @@ #include #include #include +#include using namespace icinga; @@ -147,7 +148,7 @@ void InfluxdbWriter::ExceptionHandler(boost::exception_ptr exp) Log(LogCritical, "InfluxdbWriter", "Exception during InfluxDB operation: Verify that your backend is operational!"); Log(LogDebug, "InfluxdbWriter") - << "Exception during InfluxDB operation: " << DiagnosticInformation(exp); + << "Exception during InfluxDB operation: " << DiagnosticInformation(std::move(exp)); //TODO: Close the connection, if we keep it open. } diff --git a/lib/remote/apiaction.cpp b/lib/remote/apiaction.cpp index 86f6b1f75..a2ad15737 100644 --- a/lib/remote/apiaction.cpp +++ b/lib/remote/apiaction.cpp @@ -22,8 +22,8 @@ using namespace icinga; -ApiAction::ApiAction(const std::vector& types, const Callback& action) - : m_Types(types), m_Callback(action) +ApiAction::ApiAction(std::vector types, Callback action) + : m_Types(std::move(types)), m_Callback(std::move(action)) { } Value ApiAction::Invoke(const ConfigObject::Ptr& target, const Dictionary::Ptr& params) diff --git a/lib/remote/apiaction.hpp b/lib/remote/apiaction.hpp index 97645b493..9ae6b975c 100644 --- a/lib/remote/apiaction.hpp +++ b/lib/remote/apiaction.hpp @@ -45,7 +45,7 @@ public: typedef std::function Callback; - ApiAction(const std::vector& registerTypes, const Callback& function); + ApiAction(std::vector registerTypes, Callback function); Value Invoke(const ConfigObject::Ptr& target, const Dictionary::Ptr& params); diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index 2ba8070d2..4b43d5ebc 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -27,8 +27,8 @@ using namespace icinga; ApiClient::ApiClient(const String& host, const String& port, - const String& user, const String& password) - : m_Connection(new HttpClientConnection(host, port, true)), m_User(user), m_Password(password) + String user, String password) + : m_Connection(new HttpClientConnection(host, port, true)), m_User(std::move(user)), m_Password(std::move(password)) { m_Connection->Start(); } diff --git a/lib/remote/apiclient.hpp b/lib/remote/apiclient.hpp index cd3acadfe..7507765a0 100644 --- a/lib/remote/apiclient.hpp +++ b/lib/remote/apiclient.hpp @@ -90,7 +90,7 @@ public: DECLARE_PTR_TYPEDEFS(ApiClient); ApiClient(const String& host, const String& port, - const String& user, const String& password); + String user, String password); typedef std::function&)> TypesCompletionCallback; void GetTypes(const TypesCompletionCallback& callback) const; diff --git a/lib/remote/apifunction.cpp b/lib/remote/apifunction.cpp index 4cafab1d7..b549bef29 100644 --- a/lib/remote/apifunction.cpp +++ b/lib/remote/apifunction.cpp @@ -22,8 +22,8 @@ using namespace icinga; -ApiFunction::ApiFunction(const Callback& function) - : m_Callback(function) +ApiFunction::ApiFunction(Callback function) + : m_Callback(std::move(function)) { } Value ApiFunction::Invoke(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& arguments) diff --git a/lib/remote/apifunction.hpp b/lib/remote/apifunction.hpp index a2b652da9..8e41040ab 100644 --- a/lib/remote/apifunction.hpp +++ b/lib/remote/apifunction.hpp @@ -42,7 +42,7 @@ public: typedef std::function Callback; - ApiFunction(const Callback& function); + ApiFunction(Callback function); Value Invoke(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& arguments); diff --git a/lib/remote/eventqueue.cpp b/lib/remote/eventqueue.cpp index 965f71092..80fd16059 100644 --- a/lib/remote/eventqueue.cpp +++ b/lib/remote/eventqueue.cpp @@ -24,8 +24,8 @@ using namespace icinga; -EventQueue::EventQueue(const String& name) - : m_Name(name) +EventQueue::EventQueue(String name) + : m_Name(std::move(name)) { } bool EventQueue::CanProcessEvent(const String& type) const diff --git a/lib/remote/eventqueue.hpp b/lib/remote/eventqueue.hpp index b6b4f3a48..56fe23c6f 100644 --- a/lib/remote/eventqueue.hpp +++ b/lib/remote/eventqueue.hpp @@ -37,7 +37,7 @@ class EventQueue final : public Object public: DECLARE_PTR_TYPEDEFS(EventQueue); - EventQueue(const String& name); + EventQueue(String name); bool CanProcessEvent(const String& type) const; void ProcessEvent(const Dictionary::Ptr& event); diff --git a/lib/remote/httpclientconnection.cpp b/lib/remote/httpclientconnection.cpp index 20ab83a63..28d6e50fa 100644 --- a/lib/remote/httpclientconnection.cpp +++ b/lib/remote/httpclientconnection.cpp @@ -31,8 +31,8 @@ using namespace icinga; -HttpClientConnection::HttpClientConnection(const String& host, const String& port, bool tls) - : m_Host(host), m_Port(port), m_Tls(tls) +HttpClientConnection::HttpClientConnection(String host, String port, bool tls) + : m_Host(std::move(host)), m_Port(std::move(port)), m_Tls(tls) { } void HttpClientConnection::Start() diff --git a/lib/remote/httpclientconnection.hpp b/lib/remote/httpclientconnection.hpp index 9b379e5a5..752c40c22 100644 --- a/lib/remote/httpclientconnection.hpp +++ b/lib/remote/httpclientconnection.hpp @@ -39,7 +39,7 @@ class HttpClientConnection final : public Object public: DECLARE_PTR_TYPEDEFS(HttpClientConnection); - HttpClientConnection(const String& host, const String& port, bool tls = true); + HttpClientConnection(String host, String port, bool tls = true); void Start(); diff --git a/lib/remote/httprequest.cpp b/lib/remote/httprequest.cpp index e30d4e9ad..33fe195e1 100644 --- a/lib/remote/httprequest.cpp +++ b/lib/remote/httprequest.cpp @@ -27,11 +27,11 @@ using namespace icinga; -HttpRequest::HttpRequest(const Stream::Ptr& stream) +HttpRequest::HttpRequest(Stream::Ptr stream) : Complete(false), ProtocolVersion(HttpVersion11), Headers(new Dictionary()), - m_Stream(stream), + m_Stream(std::move(stream)), m_State(HttpRequestStart) { } diff --git a/lib/remote/httprequest.hpp b/lib/remote/httprequest.hpp index 258bacdb7..b59917283 100644 --- a/lib/remote/httprequest.hpp +++ b/lib/remote/httprequest.hpp @@ -60,7 +60,7 @@ public: Dictionary::Ptr Headers; - HttpRequest(const Stream::Ptr& stream); + HttpRequest(Stream::Ptr stream); bool Parse(StreamReadContext& src, bool may_wait); size_t ReadBody(char *data, size_t count); diff --git a/lib/remote/httpresponse.cpp b/lib/remote/httpresponse.cpp index 373d088e0..f87602a24 100644 --- a/lib/remote/httpresponse.cpp +++ b/lib/remote/httpresponse.cpp @@ -27,8 +27,8 @@ using namespace icinga; -HttpResponse::HttpResponse(const Stream::Ptr& stream, const HttpRequest& request) - : Complete(false), m_State(HttpResponseStart), m_Request(request), m_Stream(stream) +HttpResponse::HttpResponse(Stream::Ptr stream, const HttpRequest& request) + : Complete(false), m_State(HttpResponseStart), m_Request(request), m_Stream(std::move(stream)) { } void HttpResponse::SetStatus(int code, const String& message) diff --git a/lib/remote/httpresponse.hpp b/lib/remote/httpresponse.hpp index 98e740a86..5ce267bf3 100644 --- a/lib/remote/httpresponse.hpp +++ b/lib/remote/httpresponse.hpp @@ -52,7 +52,7 @@ public: Dictionary::Ptr Headers; - HttpResponse(const Stream::Ptr& stream, const HttpRequest& request); + HttpResponse(Stream::Ptr stream, const HttpRequest& request); bool Parse(StreamReadContext& src, bool may_wait); size_t ReadBody(char *data, size_t count); diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 4f4977f28..af7c9f219 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -42,8 +42,8 @@ static int l_JsonRpcConnectionNextID; static Timer::Ptr l_HeartbeatTimer; JsonRpcConnection::JsonRpcConnection(const String& identity, bool authenticated, - const TlsStream::Ptr& stream, ConnectionRole role) - : m_ID(l_JsonRpcConnectionNextID++), m_Identity(identity), m_Authenticated(authenticated), m_Stream(stream), + TlsStream::Ptr stream, ConnectionRole role) + : m_ID(l_JsonRpcConnectionNextID++), m_Identity(identity), m_Authenticated(authenticated), m_Stream(std::move(stream)), m_Role(role), m_Timestamp(Utility::GetTime()), m_Seen(Utility::GetTime()), m_NextHeartbeat(0), m_HeartbeatTimeout(0) { boost::call_once(l_JsonRpcConnectionOnceFlag, &JsonRpcConnection::StaticInitialize); diff --git a/lib/remote/jsonrpcconnection.hpp b/lib/remote/jsonrpcconnection.hpp index 462ef627c..0d16606c8 100644 --- a/lib/remote/jsonrpcconnection.hpp +++ b/lib/remote/jsonrpcconnection.hpp @@ -53,7 +53,7 @@ class JsonRpcConnection final : public Object public: DECLARE_PTR_TYPEDEFS(JsonRpcConnection); - JsonRpcConnection(const String& identity, bool authenticated, const TlsStream::Ptr& stream, ConnectionRole role); + JsonRpcConnection(const String& identity, bool authenticated, TlsStream::Ptr stream, ConnectionRole role); void Start(); diff --git a/lib/remote/url.cpp b/lib/remote/url.cpp index f7e068f8c..d10a62d47 100644 --- a/lib/remote/url.cpp +++ b/lib/remote/url.cpp @@ -270,7 +270,7 @@ String Url::Format(bool onlyPathAndQuery, bool printCredentials) const // Array String temp; - for (const String s : kv.second) { + for (const String& s : kv.second) { if (!temp.IsEmpty()) temp += "&"; @@ -351,7 +351,7 @@ bool Url::ParsePort(const String& port) bool Url::ParsePath(const String& path) { - std::string pathStr = path; + const std::string& pathStr = path; boost::char_separator sep("/"); boost::tokenizer > tokens(pathStr, sep); @@ -371,7 +371,7 @@ bool Url::ParsePath(const String& path) bool Url::ParseQuery(const String& query) { /* Tokenizer does not like String AT ALL */ - std::string queryStr = query; + const std::string& queryStr = query; boost::char_separator sep("&"); boost::tokenizer > tokens(queryStr, sep); diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 047d4670b..3d48c25f5 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -35,9 +36,9 @@ using namespace icinga; -ClassCompiler::ClassCompiler(const std::string& path, std::istream& input, +ClassCompiler::ClassCompiler(std::string path, std::istream& input, std::ostream& oimpl, std::ostream& oheader) - : m_Path(path), m_Input(input), m_Impl(oimpl), m_Header(oheader) + : m_Path(std::move(path)), m_Input(input), m_Impl(oimpl), m_Header(oheader) { InitializeScanner(); } diff --git a/tools/mkclass/classcompiler.hpp b/tools/mkclass/classcompiler.hpp index 67a50070d..d01d5e90c 100644 --- a/tools/mkclass/classcompiler.hpp +++ b/tools/mkclass/classcompiler.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -53,8 +54,8 @@ struct FieldAccessor std::string Accessor; bool Pure; - FieldAccessor(FieldAccessorType type, const std::string& accessor, bool pure) - : Type(type), Accessor(accessor), Pure(pure) + FieldAccessor(FieldAccessorType type, std::string accessor, bool pure) + : Type(type), Accessor(std::move(accessor)), Pure(pure) { } }; @@ -207,7 +208,7 @@ struct Validator class ClassCompiler { public: - ClassCompiler(const std::string& path, std::istream& input, std::ostream& oimpl, std::ostream& oheader); + ClassCompiler(std::string path, std::istream& input, std::ostream& oimpl, std::ostream& oheader); ~ClassCompiler(); void Compile();