]> granicus.if.org Git - icinga2/commitdiff
Use std::vector::emplace_back instead of std::vector::push_back
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 30 Nov 2017 07:19:58 +0000 (08:19 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 30 Nov 2017 16:47:09 +0000 (17:47 +0100)
53 files changed:
lib/base/array-script.cpp
lib/base/array.cpp
lib/base/function-script.cpp
lib/base/function.cpp
lib/base/function.hpp
lib/base/socketevents-epoll.cpp
lib/base/socketevents-poll.cpp
lib/base/threadpool.cpp
lib/base/typetype-script.cpp
lib/base/utility.cpp
lib/cli/apisetuputility.cpp
lib/cli/daemoncommand.cpp
lib/cli/troubleshootcommand.cpp
lib/compat/statusdatawriter.cpp
lib/config/config_parser.yy
lib/config/configitem.cpp
lib/config/vmops.hpp
lib/db_ido/dbconnection.cpp
lib/db_ido/dbevents.cpp
lib/db_ido/dbobject.cpp
lib/db_ido/hostdbobject.cpp
lib/db_ido/idochecktask.cpp
lib/db_ido/servicedbobject.cpp
lib/db_ido/userdbobject.cpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/icinga/checkcommand.cpp
lib/icinga/eventcommand.cpp
lib/icinga/macroprocessor.cpp
lib/icinga/notificationcommand.cpp
lib/icinga/timeperiod.cpp
lib/livestatus/hoststable.cpp
lib/livestatus/livestatusquery.cpp
lib/livestatus/servicestable.cpp
lib/livestatus/table.cpp
lib/methods/clrchecktask.cpp
lib/methods/clusterzonechecktask.cpp
lib/methods/dummychecktask.cpp
lib/methods/pluginchecktask.cpp
lib/methods/plugineventtask.cpp
lib/methods/pluginnotificationtask.cpp
lib/perfdata/elasticsearchwriter.cpp
lib/perfdata/graphitewriter.cpp
lib/perfdata/influxdbwriter.cpp
lib/perfdata/perfdatawriter.cpp
lib/remote/apiclient.cpp
lib/remote/apilistener.cpp
lib/remote/configpackageutility.cpp
lib/remote/filterutility.cpp
lib/remote/httpclientconnection.cpp
lib/remote/httphandler.cpp
lib/remote/httpresponse.cpp
lib/remote/infohandler.cpp
lib/remote/url.cpp

index dd9d5628d8b6aa95141e4b7000f8a6730ae50a5f..54fb394ec12ddab3aee178b75046d1bd36bb8e40 100644 (file)
@@ -77,10 +77,7 @@ static void ArrayClear(void)
 
 static bool ArraySortCmp(const Function::Ptr& cmp, const Value& a, const Value& b)
 {
-       std::vector<Value> args;
-       args.push_back(a);
-       args.push_back(b);
-       return cmp->Invoke(args);
+       return cmp->Invoke({ a, b });
 }
 
 static Array::Ptr ArraySort(const std::vector<Value>& args)
@@ -154,9 +151,7 @@ static Array::Ptr ArrayMap(const Function::Ptr& function)
 
        ObjectLock olock(self);
        for (const Value& item : self) {
-               std::vector<Value> args;
-               args.push_back(item);
-               result->Add(function->Invoke(args));
+               result->Add(function->Invoke({ item }));
        }
 
        return result;
@@ -177,10 +172,7 @@ static Value ArrayReduce(const Function::Ptr& function)
 
        ObjectLock olock(self);
        for (size_t i = 1; i < self->GetLength(); i++) {
-               std::vector<Value> args;
-               args.push_back(result);
-               args.push_back(self->Get(i));
-               result = function->Invoke(args);
+               result = function->Invoke({ result, self->Get(i) });
        }
 
        return result;
@@ -198,9 +190,7 @@ static Array::Ptr ArrayFilter(const Function::Ptr& function)
 
        ObjectLock olock(self);
        for (const Value& item : self) {
-               std::vector<Value> args;
-               args.push_back(item);
-               if (function->Invoke(args))
+               if (function->Invoke({ item }))
                        result->Add(item);
        }
 
@@ -217,9 +207,7 @@ static bool ArrayAny(const Function::Ptr& function)
 
        ObjectLock olock(self);
        for (const Value& item : self) {
-               std::vector<Value> args;
-               args.push_back(item);
-               if (function->Invoke(args))
+               if (function->Invoke({ item }))
                        return true;
        }
 
@@ -236,9 +224,7 @@ static bool ArrayAll(const Function::Ptr& function)
 
        ObjectLock olock(self);
        for (const Value& item : self) {
-               std::vector<Value> args;
-               args.push_back(item);
-               if (!function->Invoke(args))
+               if (!function->Invoke({ item }))
                        return false;
        }
 
index 243f88ecd05d517afbfa8acc387b44a16f70d369..a493e81778a5fc0c015bbf876b7b4fde63aa52c0 100644 (file)
@@ -90,7 +90,7 @@ void Array::Add(Value&& value)
 {
        ObjectLock olock(this);
 
-       m_Data.push_back(std::move(value));
+       m_Data.emplace_back(std::move(value));
 }
 
 /**
index 09e85939d03cb9f7c3618e1646a801c7fbc6b299..2df59cc374f675145e4e9fbbb00062bbd3a8072f 100644 (file)
@@ -34,7 +34,7 @@ static Value FunctionCall(const std::vector<Value>& args)
        Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
 
        std::vector<Value> uargs(args.begin() + 1, args.end());
-       return self->Invoke(args[0], uargs);
+       return self->InvokeThis(args[0], uargs);
 }
 
 static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
@@ -49,7 +49,7 @@ static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
                uargs = std::vector<Value>(args->Begin(), args->End());
        }
 
-       return self->Invoke(thisArg, uargs);
+       return self->InvokeThis(thisArg, uargs);
 }
 
 
index 8cc2337742f8abdd326ab0859c52c63ad6832c21..cb34d835fd9abdc8e1f027d92587c580f2a0600e 100644 (file)
@@ -42,7 +42,7 @@ Value Function::Invoke(const std::vector<Value>& arguments)
        return m_Callback(arguments);
 }
 
-Value Function::Invoke(const Value& otherThis, const std::vector<Value>& arguments)
+Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
 {
        ScriptFrame frame;
        frame.Self = otherThis;
index 6f257863f7de54642a703dc24084bfdd49a7ec47..6dc0700805e07597087eaa5e745494c1bdc4cea5 100644 (file)
@@ -49,7 +49,7 @@ public:
        { }
 
        Value Invoke(const std::vector<Value>& arguments = std::vector<Value>());
-       Value Invoke(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
+       Value InvokeThis(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
 
        inline bool IsSideEffectFree(void) const
        {
index dadd40117b649f4ec833e5a57087f19c0e5c5655..589fe789a34f4b363fa1358ad4d32af0468bf5b7 100644 (file)
@@ -116,7 +116,7 @@ void SocketEventEngineEpoll::ThreadProc(int tid)
                                event.LifesupportReference = event.Descriptor.LifesupportObject;
                                VERIFY(event.LifesupportReference);
 
-                               events.push_back(event);
+                               events.emplace_back(std::move(event));
                        }
                }
 
index d141abe951cb7710cfa7df5a5c298324bc1f5203..3c9539cf0a51b7bb4f43ed843ff922b5a64b2226 100644 (file)
@@ -108,7 +108,7 @@ void SocketEventEnginePoll::ThreadProc(int tid)
                                event.LifesupportReference = event.Descriptor.LifesupportObject;
                                VERIFY(event.LifesupportReference);
 
-                               events.push_back(event);
+                               events.emplace_back(std::move(event));
                        }
                }
 
index 8b9b4705c4550a88b0979b5fb5734ab44b3bc787..683a6b6ddfea70721c563a2a05771010f28b5dd4 100644 (file)
@@ -212,7 +212,7 @@ bool ThreadPool::Post(const ThreadPool::WorkFunction& callback, SchedulerPolicy
                if (policy == LowLatencyScheduler)
                        queue.SpawnWorker(m_ThreadGroup);
 
-               queue.Items.push_back(wi);
+               queue.Items.emplace_back(std::move(wi));
                queue.CV.notify_one();
        }
 
index 66452fdcc3bf39f899dda19f6ab283dca094af33..21ef5d572ffe4f6bd513ceb2c871e5955ac11281 100644 (file)
@@ -28,9 +28,7 @@ using namespace icinga;
 static void InvokeAttributeHandlerHelper(const Function::Ptr& callback,
     const Object::Ptr& object, const Value& cookie)
 {
-       std::vector<Value> arguments;
-       arguments.push_back(object);
-       callback->Invoke(arguments);
+       callback->Invoke({ object });
 }
 
 static void TypeRegisterAttributeHandler(const String& fieldName, const Function::Ptr& callback)
index ce6aa572dc9717855fe0370a0180ae78728db442..fddc40cfc96bfc1b13f21898104589d685d41a33 100644 (file)
@@ -976,31 +976,31 @@ String Utility::FormatDuration(double duration)
 
        if (duration >= 86400) {
                int days = duration / 86400;
-               tokens.push_back(Convert::ToString(days) + (days != 1 ? " days" : " day"));
+               tokens.emplace_back(Convert::ToString(days) + (days != 1 ? " days" : " day"));
                duration = static_cast<int>(duration) % 86400;
        }
 
        if (duration >= 3600) {
                int hours = duration / 3600;
-               tokens.push_back(Convert::ToString(hours) + (hours != 1 ? " hours" : " hour"));
+               tokens.emplace_back(Convert::ToString(hours) + (hours != 1 ? " hours" : " hour"));
                duration = static_cast<int>(duration) % 3600;
        }
 
        if (duration >= 60) {
                int minutes = duration / 60;
-               tokens.push_back(Convert::ToString(minutes) + (minutes != 1 ? " minutes" : " minute"));
+               tokens.emplace_back(Convert::ToString(minutes) + (minutes != 1 ? " minutes" : " minute"));
                duration = static_cast<int>(duration) % 60;
        }
 
        if (duration >= 1) {
                int seconds = duration;
-               tokens.push_back(Convert::ToString(seconds) + (seconds != 1 ? " seconds" : " second"));
+               tokens.emplace_back(Convert::ToString(seconds) + (seconds != 1 ? " seconds" : " second"));
        }
 
        if (tokens.size() == 0) {
                int milliseconds = std::floor(duration * 1000);
                if (milliseconds >= 1)
-                       tokens.push_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
+                       tokens.emplace_back(Convert::ToString(milliseconds) + (milliseconds != 1 ? " milliseconds" : " millisecond"));
                else
                        tokens.push_back("less than 1 millisecond");
        }
index b658f9339937691b0cc892ebe9989da0a48664af..4186475d883d17943e6ee10d9ba104007b8d3001 100644 (file)
@@ -132,16 +132,7 @@ bool ApiSetupUtility::SetupMasterCertificates(const String& cn)
        Utility::CopyFile(ca, target_ca);
 
        /* fix permissions: root -> icinga daemon user */
-       std::vector<String> files;
-       files.push_back(ca_path);
-       files.push_back(ca);
-       files.push_back(ca_key);
-       files.push_back(target_ca);
-       files.push_back(key);
-       files.push_back(csr);
-       files.push_back(cert);
-
-       for (const String& file : files) {
+       for (const String& file : { ca_path, ca, ca_key, target_ca, key, csr, cert }) {
                if (!Utility::SetFileOwnership(file, user, group)) {
                        Log(LogWarning, "cli")
                            << "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << file << "'.";
@@ -201,9 +192,7 @@ bool ApiSetupUtility::SetupMasterEnableApi(void)
 {
        Log(LogInformation, "cli", "Enabling the 'api' feature.");
 
-       std::vector<std::string> features;
-       features.push_back("api");
-       FeatureUtility::EnableFeatures(features);
+       FeatureUtility::EnableFeatures({ "api" });
 
        return true;
 }
index 6459fe2fb519c7c2677f48faa06aff0f0f9f6f07..e9d0d60d6dd97941cd22d562bf85060b9d7eacf9 100644 (file)
@@ -234,7 +234,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
 
        std::vector<std::string> configs;
        if (vm.count("config") > 0)
-               configs = vm["config"].as < std::vector<std::string> >() ;
+               configs = vm["config"].as<std::vector<std::string> >();
        else if (!vm.count("no-config"))
                configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
 
index a8e5d4b4276ca7fb9a09a6701f73367d8429ab00..28ea6cb72ff80dc39ebb2dd4f58043a7fa4d924d 100644 (file)
@@ -444,10 +444,7 @@ bool TroubleshootCommand::PrintFile(InfoLog& log, const String& path)
 
 bool TroubleshootCommand::CheckConfig(void)
 {
-       std::vector<std::string> configs;
-       configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
-
-       return DaemonUtility::ValidateConfigFiles(configs, Application::GetObjectsPath());
+       return DaemonUtility::ValidateConfigFiles({ Application::GetSysconfDir() + "/icinga2/icinga2.conf" }, Application::GetObjectsPath());
 }
 
 //print is supposed allow the user to print the object file
index d672580359ca2d0c748bcbfe8ea7d603a119d60b..ec9c7c8c9a76c00fc2641f932e8f2b3fa8a90abf 100644 (file)
@@ -634,8 +634,8 @@ void StatusDataWriter::UpdateObjectsCache(void)
                for (const Service::Ptr& service : sg->GetMembers()) {
                        Host::Ptr host = service->GetHost();
 
-                       sglist.push_back(host->GetName());
-                       sglist.push_back(service->GetShortName());
+                       sglist.emplace_back(host->GetName());
+                       sglist.emplace_back(service->GetShortName());
                }
 
                DumpStringList(tempobjectfp, sglist);
@@ -734,15 +734,15 @@ void StatusDataWriter::UpdateObjectsCache(void)
                int state_filter = dep->GetStateFilter();
                std::vector<String> failure_criteria;
                if (state_filter & StateFilterOK || state_filter & StateFilterUp)
-                       failure_criteria.push_back("o");
+                       failure_criteria.emplace_back("o");
                if (state_filter & StateFilterWarning)
-                       failure_criteria.push_back("w");
+                       failure_criteria.emplace_back("w");
                if (state_filter & StateFilterCritical)
-                       failure_criteria.push_back("c");
+                       failure_criteria.emplace_back("c");
                if (state_filter & StateFilterUnknown)
-                       failure_criteria.push_back("u");
+                       failure_criteria.emplace_back("u");
                if (state_filter & StateFilterDown)
-                       failure_criteria.push_back("d");
+                       failure_criteria.emplace_back("d");
 
                String criteria = boost::algorithm::join(failure_criteria, ",");
 
index 36f97241051f9ab8c03c578f8b7d59c31c9020c0..688429a53ff74bfea068930f0cbefa9d8294cfdb 100644 (file)
@@ -328,13 +328,13 @@ lterm_items_inner: lterm %dprec 2
        {
                $$ = new std::vector<std::pair<Expression *, EItemInfo> >();
                EItemInfo info = { true, @1 };
-               $$->push_back(std::make_pair($1, info));
+               $$->emplace_back($1, info);
        }
        | rterm_no_side_effect
        {
                $$ = new std::vector<std::pair<Expression *, EItemInfo> >();
                EItemInfo info = { false, @1 };
-               $$->push_back(std::make_pair($1, info));
+               $$->emplace_back($1, info);
        }
        | lterm_items_inner sep lterm %dprec 1
        {
@@ -345,7 +345,7 @@ lterm_items_inner: lterm %dprec 2
 
                if ($3) {
                        EItemInfo info = { true, @3 };
-                       $$->push_back(std::make_pair($3, info));
+                       $$->emplace_back($3, info);
                }
        }
        | lterm_items_inner sep rterm_no_side_effect %dprec 1
@@ -357,7 +357,7 @@ lterm_items_inner: lterm %dprec 2
 
                if ($3) {
                        EItemInfo info = { false, @3 };
-                       $$->push_back(std::make_pair($3, info));
+                       $$->emplace_back($3, info);
                }
        }
        ;
index 0ab2a071224759584a6216bce340ea68c043b61d..edb0527bae1576461ade0ff46763703b2fb5c4e6 100644 (file)
@@ -404,7 +404,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
                                if (kv2.second->m_ActivationContext != context)
                                        continue;
 
-                               items.push_back(std::make_pair(kv2.second, false));
+                               items.emplace_back(kv2.second, false);
                        }
                }
 
@@ -419,7 +419,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
                        if (item->m_Abstract || item->m_Object)
                                continue;
 
-                       items.push_back(std::make_pair(item, true));
+                       items.emplace_back(item, true);
                }
 
                m_UnnamedItems.swap(newUnnamedItems);
index 193a57ab50eba691d9166d3432b25b7ca4c072d9..4376f32d76d533a1de1b69269526ebf4d3d8e8cf 100644 (file)
@@ -102,7 +102,7 @@ public:
        static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Function::Ptr& func, const std::vector<Value>& arguments)
        {
                if (!self.IsEmpty() || self.IsString())
-                       return func->Invoke(self, arguments);
+                       return func->InvokeThis(self, arguments);
                else
                        return func->Invoke(arguments);
 
index 96a744fdc139e3a796a633654614de30b2f095b7..a9b189ade0b17778ed3ce6969bea93f46020d3c9 100644 (file)
@@ -181,13 +181,12 @@ void DbConnection::UpdateProgramStatus(void)
        query1.Fields->Set("process_performance_data", (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0));
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("instance_id", 0);  /* DbConnection class fills in real ID */
-
        query1.Priority = PriorityHigh;
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        DbQuery query2;
        query2.Type = DbQueryNewTransaction;
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 
        DbObject::OnMultipleQueries(queries);
 
index b14b19ce67b27e296d98c527252fb82ab9cbea96..d67901c907ed9bd4472bba2249ee48201fe809ea 100644 (file)
@@ -383,8 +383,7 @@ void DbEvents::AddCommentInternal(std::vector<DbQuery>& queries, const Comment::
        }
        query1.Category = DbCatComment;
        query1.Fields = fields1;
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 }
 
 void DbEvents::RemoveComment(const Comment::Ptr& comment)
@@ -409,7 +408,7 @@ void DbEvents::RemoveCommentInternal(std::vector<DbQuery>& queries, const Commen
        query1.WhereCriteria->Set("object_id", checkable);
        query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time));
        query1.WhereCriteria->Set("name", comment->GetName());
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        /* History - update deletion time for service/host */
        double now = Utility::GetTime();
@@ -429,7 +428,7 @@ void DbEvents::RemoveCommentInternal(std::vector<DbQuery>& queries, const Commen
        query2.WhereCriteria->Set("object_id", checkable);
        query2.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time));
        query2.WhereCriteria->Set("name", comment->GetName());
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 }
 
 /* downtimes */
@@ -526,8 +525,7 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
 
        query1.Category = DbCatDowntime;
        query1.Fields = fields1;
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        /* host/service status */
        if (!historical) {
@@ -558,8 +556,7 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
                        query2.WhereCriteria->Set("host_object_id", host);
 
                query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
-               queries.push_back(query2);
+               queries.emplace_back(std::move(query2));
        }
 }
 
@@ -587,7 +584,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
        query1.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
        query1.WhereCriteria->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
        query1.WhereCriteria->Set("name", downtime->GetName());
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        /* History - update actual_end_time, was_cancelled for service (and host in case) */
        double now = Utility::GetTime();
@@ -616,8 +613,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
        query3.WhereCriteria->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
        query3.WhereCriteria->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
        query3.WhereCriteria->Set("name", downtime->GetName());
-
-       queries.push_back(query3);
+       queries.emplace_back(std::move(query3));
 
        /* host/service status */
        Host::Ptr host;
@@ -647,8 +643,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
                query4.WhereCriteria->Set("host_object_id", host);
 
        query4.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
-
-       queries.push_back(query4);
+       queries.emplace_back(std::move(query4));
 }
 
 void DbEvents::TriggerDowntime(const Downtime::Ptr& downtime)
@@ -908,7 +903,7 @@ void DbEvents::AddNotificationHistory(const Notification::Ptr& notification, con
                fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
 
                query2.Fields = fields2;
-               queries.push_back(query2);
+               queries.emplace_back(std::move(query2));
        }
 
        DbObject::OnMultipleQueries(queries);
index a40e7d77543392500740daf862ed046bee276825..a606a2e6733eb4789e49a0307b8ce9c1ab0e0703 100644 (file)
@@ -217,8 +217,7 @@ void DbObject::SendVarsConfigUpdateHeavy(void)
        query1.Category = DbCatConfig;
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("object_id", obj);
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        DbQuery query2;
        query2.Table = "customvariablestatus";
@@ -226,8 +225,7 @@ void DbObject::SendVarsConfigUpdateHeavy(void)
        query2.Category = DbCatConfig;
        query2.WhereCriteria = new Dictionary();
        query2.WhereCriteria->Set("object_id", obj);
-
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 
        Dictionary::Ptr vars = CompatUtility::GetCustomAttributeConfig(custom_var_object);
 
@@ -260,8 +258,7 @@ void DbObject::SendVarsConfigUpdateHeavy(void)
                        query3.Type = DbQueryInsert;
                        query3.Category = DbCatConfig;
                        query3.Fields = fields;
-
-                       queries.push_back(query3);
+                       queries.emplace_back(std::move(query3));
                }
        }
 
@@ -313,8 +310,7 @@ void DbObject::SendVarsStatusUpdate(void)
                        query.WhereCriteria = new Dictionary();
                        query.WhereCriteria->Set("object_id", obj);
                        query.WhereCriteria->Set("varname", kv.first);
-
-                       queries.push_back(query);
+                       queries.emplace_back(std::move(query));
                }
 
                OnMultipleQueries(queries);
index aa1a32a08545cd5ac7773f49a36f7dfd32de6700..eb5ae574110a8d689ee431158728786b650149d3 100644 (file)
@@ -191,8 +191,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
        query1.Category = DbCatConfig;
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("host_object_id", host);
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        if (groups) {
                ObjectLock olock(groups);
@@ -211,8 +210,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
                        query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
                        query2.WhereCriteria->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
                        query2.WhereCriteria->Set("host_object_id", host);
-
-                       queries.push_back(query2);
+                       queries.emplace_back(std::move(query2));
                }
        }
 
@@ -226,8 +224,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
        query2.Category = DbCatConfig;
        query2.WhereCriteria = new Dictionary();
        query2.WhereCriteria->Set(GetType()->GetTable() + "_id", DbValue::FromObjectInsertID(GetObject()));
-
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 
        /* parents */
        for (const Checkable::Ptr& checkable : host->GetParents()) {
@@ -250,8 +247,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
                query1.Type = DbQueryInsert;
                query1.Category = DbCatConfig;
                query1.Fields = fields1;
-
-               queries.push_back(query1);
+               queries.emplace_back(std::move(query1));
        }
 
        DbObject::OnMultipleQueries(queries);
@@ -268,8 +264,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
        query3.Category = DbCatConfig;
        query3.WhereCriteria = new Dictionary();
        query3.WhereCriteria->Set("dependent_host_object_id", host);
-
-       queries.push_back(query3);
+       queries.emplace_back(std::move(query3));
 
        for (const Dependency::Ptr& dep : host->GetDependencies()) {
                Checkable::Ptr parent = dep->GetParent();
@@ -299,8 +294,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
                query2.Type = DbQueryInsert;
                query2.Category = DbCatConfig;
                query2.Fields = fields2;
-
-               queries.push_back(query2);
+               queries.emplace_back(std::move(query2));
        }
 
        DbObject::OnMultipleQueries(queries);
@@ -316,8 +310,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
        query4.Category = DbCatConfig;
        query4.WhereCriteria = new Dictionary();
        query4.WhereCriteria->Set("host_id", DbValue::FromObjectInsertID(host));
-
-       queries.push_back(query4);
+       queries.emplace_back(std::move(query4));
 
        for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) {
                Log(LogDebug, "HostDbObject")
@@ -333,8 +326,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
                query_contact.Type = DbQueryInsert;
                query_contact.Category = DbCatConfig;
                query_contact.Fields = fields_contact;
-
-               queries.push_back(query_contact);
+               queries.emplace_back(std::move(query_contact));
        }
 
        DbObject::OnMultipleQueries(queries);
@@ -350,8 +342,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
        query5.Category = DbCatConfig;
        query5.WhereCriteria = new Dictionary();
        query5.WhereCriteria->Set("host_id", DbValue::FromObjectInsertID(host));
-
-       queries.push_back(query5);
+       queries.emplace_back(std::move(query5));
 
        for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(host)) {
                Log(LogDebug, "HostDbObject")
@@ -367,8 +358,7 @@ void HostDbObject::OnConfigUpdateHeavy(void)
                query_contact.Type = DbQueryInsert;
                query_contact.Category = DbCatConfig;
                query_contact.Fields = fields_contact;
-
-               queries.push_back(query_contact);
+               queries.emplace_back(std::move(query_contact));
        }
 
        DbObject::OnMultipleQueries(queries);
index 707b1ed3796cb300b609cef15071df1d5847dc1a..b3c11eefd90df15f807743acbd9a5de153a671b6 100644 (file)
@@ -46,10 +46,10 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String idoType = MacroProcessor::ResolveMacros("$ido_type$", resolvers, checkable->GetLastCheckResult(),
            NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
index 378d3f45700670387664ff5f1c1a4b84e2aa8222..0086dc9ecf29df421bd5a823b0a448221bf4da58 100644 (file)
@@ -185,8 +185,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
        query1.Category = DbCatConfig;
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("service_object_id", service);
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        if (groups) {
                ObjectLock olock(groups);
@@ -205,8 +204,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
                        query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
                        query2.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
                        query2.WhereCriteria->Set("service_object_id", service);
-
-                       queries.push_back(query2);
+                       queries.emplace_back(std::move(query2));
                }
        }
 
@@ -224,8 +222,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
        query2.Category = DbCatConfig;
        query2.WhereCriteria = new Dictionary();
        query2.WhereCriteria->Set("dependent_service_object_id", service);
-
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 
        for (const Dependency::Ptr& dep : service->GetDependencies()) {
                Checkable::Ptr parent = dep->GetParent();
@@ -258,8 +255,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
                query1.Type = DbQueryInsert;
                query1.Category = DbCatConfig;
                query1.Fields = fields1;
-
-               queries.push_back(query1);
+               queries.emplace_back(std::move(query1));
        }
 
        DbObject::OnMultipleQueries(queries);
@@ -276,8 +272,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
        query3.Category = DbCatConfig;
        query3.WhereCriteria = new Dictionary();
        query3.WhereCriteria->Set("service_id", DbValue::FromObjectInsertID(service));
-
-       queries.push_back(query3);
+       queries.emplace_back(std::move(query3));
 
        for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
                Log(LogDebug, "ServiceDbObject")
@@ -293,8 +288,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
                query_contact.Type = DbQueryInsert;
                query_contact.Category = DbCatConfig;
                query_contact.Fields = fields_contact;
-
-               queries.push_back(query_contact);
+               queries.emplace_back(std::move(query_contact));
        }
 
        DbObject::OnMultipleQueries(queries);
@@ -310,8 +304,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
        query4.Category = DbCatConfig;
        query4.WhereCriteria = new Dictionary();
        query4.WhereCriteria->Set("service_id", DbValue::FromObjectInsertID(service));
-
-       queries.push_back(query4);
+       queries.emplace_back(std::move(query4));
 
        for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) {
                Log(LogDebug, "ServiceDbObject")
@@ -327,8 +320,7 @@ void ServiceDbObject::OnConfigUpdateHeavy(void)
                query_contact.Type = DbQueryInsert;
                query_contact.Category = DbCatConfig;
                query_contact.Fields = fields_contact;
-
-               queries.push_back(query_contact);
+               queries.emplace_back(std::move(query_contact));
        }
 
        DbObject::OnMultipleQueries(queries);
index 9e25b8be4d117871bf02c8f26b3cf1001ec996f9..fae23d925045a8dfe0a364333775de80cadd36e5 100644 (file)
@@ -94,8 +94,7 @@ void UserDbObject::OnConfigUpdateHeavy(void)
        query1.Category = DbCatConfig;
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("contact_object_id", user);
-
-       queries.push_back(query1);
+       queries.emplace_back(std::move(query1));
 
        if (groups) {
                ObjectLock olock(groups);
@@ -114,8 +113,7 @@ void UserDbObject::OnConfigUpdateHeavy(void)
                        query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
                        query2.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
                        query2.WhereCriteria->Set("contact_object_id", user);
-
-                       queries.push_back(query2);
+                       queries.emplace_back(std::move(query2));
                }
        }
 
@@ -129,8 +127,7 @@ void UserDbObject::OnConfigUpdateHeavy(void)
        query2.Category = DbCatConfig;
        query2.WhereCriteria = new Dictionary();
        query2.WhereCriteria->Set("contact_id", DbValue::FromObjectInsertID(user));
-
-       queries.push_back(query2);
+       queries.emplace_back(std::move(query2));
 
        Dictionary::Ptr vars = user->GetVars();
 
@@ -155,8 +152,7 @@ void UserDbObject::OnConfigUpdateHeavy(void)
                        query.Table = "contact_addresses";
                        query.Category = DbCatConfig;
                        query.Fields = fields;
-
-                       queries.push_back(query);
+                       queries.emplace_back(std::move(query));
                }
        }
 
index bc737b1664a303248cafe640c3931a2a9de274d8..1ed3a8c97917925082d743167880dc7d39f63f85 100644 (file)
@@ -420,7 +420,7 @@ void IdoMysqlConnection::Reconnect(void)
                SetObjectActive(dbobj, active);
 
                if (active)
-                       activeDbObjs.push_back(dbobj);
+                       activeDbObjs.emplace_back(std::move(dbobj));
        }
 
        SetIDCacheValid(true);
@@ -489,7 +489,7 @@ void IdoMysqlConnection::AsyncQuery(const String& query, const std::function<voi
         * See https://github.com/Icinga/icinga2/issues/4603 for details.
         */
        aq.Callback = callback;
-       m_AsyncQueries.push_back(aq);
+       m_AsyncQueries.emplace_back(std::move(aq));
 
        if (m_AsyncQueries.size() > 25000) {
                FinishAsyncQueries();
index e300515b9c3d223edf3f9cd416f6ebb94cf6fb2e..167701a2e794ace3d51c446ce02689cba04967dc 100644 (file)
@@ -28,10 +28,10 @@ REGISTER_TYPE(CheckCommand);
 void CheckCommand::Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
-       std::vector<Value> arguments;
-       arguments.push_back(checkable);
-       arguments.push_back(cr);
-       arguments.push_back(resolvedMacros);
-       arguments.push_back(useResolvedMacros);
-       GetExecute()->Invoke(arguments);
+       GetExecute()->Invoke({
+           checkable,
+           cr,
+           resolvedMacros,
+           useResolvedMacros
+       });
 }
index 54d54851c6d5352c477e430bb931c612d355b660..886c89203a010f5d70f5add1dc619482e7112899 100644 (file)
@@ -27,9 +27,9 @@ REGISTER_TYPE(EventCommand);
 void EventCommand::Execute(const Checkable::Ptr& checkable,
     const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
 {
-       std::vector<Value> arguments;
-       arguments.push_back(checkable);
-       arguments.push_back(resolvedMacros);
-       arguments.push_back(useResolvedMacros);
-       GetExecute()->Invoke(arguments);
+       GetExecute()->Invoke({
+           checkable,
+           resolvedMacros,
+           useResolvedMacros
+       });
 }
index c97bd1b67af11e05079198b95fbb50c75a5b1a19..465667ed4e241793ca3c07604e2d476c315c8141 100644 (file)
@@ -222,8 +222,7 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver
            _1, std::cref(resolvers), cr, resolvedMacros, useResolvedMacros,
            recursionLevel + 1)));
 
-       std::vector<Value> args;
-       return func->Invoke(resolvers_this, args);
+       return func->InvokeThis(resolvers_this);
 }
 
 Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverList& resolvers,
@@ -542,7 +541,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P
                                continue;
                        }
 
-                       args.push_back(arg);
+                       args.emplace_back(std::move(arg));
                }
 
                std::sort(args.begin(), args.end());
index fc99872f840bf8c30650e5404eaede16c8c864a3..3313b76afd774a9ce3c4aff87f70cb3c9b407ac9 100644 (file)
@@ -29,14 +29,14 @@ Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notificati
     const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
     bool useResolvedMacros)
 {
-       std::vector<Value> arguments;
-       arguments.push_back(notification);
-       arguments.push_back(user);
-       arguments.push_back(cr);
-       arguments.push_back(type);
-       arguments.push_back(author);
-       arguments.push_back(comment);
-       arguments.push_back(resolvedMacros);
-       arguments.push_back(useResolvedMacros);
-       return GetExecute()->Invoke(arguments);
+       return GetExecute()->Invoke({
+           notification,
+           user,
+           cr,
+           type,
+           author,
+           comment,
+           resolvedMacros,
+           useResolvedMacros,
+       });
 }
index f0b8b66447f1f6c2d25028ed7f96413a78e34764..ffb7fe864dc29ca706b05ae7fac57e81bc126f7d 100644 (file)
@@ -244,12 +244,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
                        return;
        }
 
-       std::vector<Value> arguments;
-       arguments.push_back(this);
-       arguments.push_back(begin);
-       arguments.push_back(end);
-
-       Array::Ptr segments = GetUpdate()->Invoke(arguments);
+       Array::Ptr segments = GetUpdate()->Invoke({ this, begin, end });
 
        {
                ObjectLock olock(this);
index ce4cb2a83b35d18170b34e4f56f972d389ef11ba..e98a1aa251f200ecdaa1fec6967051fe3d5c3d51 100644 (file)
@@ -323,9 +323,10 @@ Value HostsTable::NotesExpandedAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "host", host },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers, CheckResult::Ptr());
 }
@@ -347,9 +348,10 @@ Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "host", host },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(host->GetNotesUrl(), resolvers);
 }
@@ -371,9 +373,10 @@ Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "host", host },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(host->GetActionUrl(), resolvers);
 }
@@ -427,9 +430,10 @@ Value HostsTable::IconImageExpandedAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "host", host },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(host->GetIconImage(), resolvers);
 }
index 3132fe53232d70da4f9d0c00f094361c2c9412b9..6dbb52c9a9906ceff5b3bde083d86ae9df9c9499 100644 (file)
@@ -309,12 +309,12 @@ Filter::Ptr LivestatusQuery::ParseFilter(const String& params, unsigned long& fr
                        break;
                }
 
-               tokens.push_back(temp_buffer.SubStr(0, sp_index));
+               tokens.emplace_back(temp_buffer.SubStr(0, sp_index));
                temp_buffer = temp_buffer.SubStr(sp_index + 1);
        }
 
        /* add the rest as value */
-       tokens.push_back(temp_buffer);
+       tokens.emplace_back(std::move(temp_buffer));
 
        if (tokens.size() == 2)
                tokens.push_back("");
@@ -490,7 +490,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream)
                column_objs.reserve(columns.size());
 
                for (const String& columnName : columns)
-                       column_objs.push_back(std::make_pair(columnName, table->GetColumn(columnName)));
+                       column_objs.emplace_back(columnName, table->GetColumn(columnName));
 
                for (const LivestatusRowValue& object : objects) {
                        Array::Ptr row = new Array();
@@ -520,7 +520,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream)
 
                        for (const String& columnName : m_Columns) {
                                Column column = table->GetColumn(columnName);
-                               statsKey.push_back(column.ExtractValue(object.Row, object.GroupByType, object.GroupByObject));
+                               statsKey.emplace_back(column.ExtractValue(object.Row, object.GroupByType, object.GroupByObject));
                        }
 
                        auto it = allStats.find(statsKey);
index d7583da2cb6ded264473a231b76faa141ff7b93b..76baa3bcaa451578865ce14ba19ae0780fd2bbbc 100644 (file)
@@ -375,10 +375,11 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", service->GetHost()));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "service", service },
+           { "host", service->GetHost() },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers);
 }
@@ -400,10 +401,11 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", service->GetHost()));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "service", service },
+           { "host", service->GetHost() },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers);
 }
@@ -425,10 +427,11 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", service->GetHost()));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "service", service },
+           { "host", service->GetHost() },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers);
 }
@@ -450,10 +453,11 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", service->GetHost()));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+       MacroProcessor::ResolverList resolvers {
+           { "service", service },
+           { "host", service->GetHost() },
+           { "icinga", IcingaApplication::GetInstance() }
+       };
 
        return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers);
 }
index 34659f18c25d2ec44c064e7f6e5466e486e3705f..1e121ecb109d07c665286ffc9e83c48f7fd6b556 100644 (file)
@@ -144,8 +144,7 @@ bool Table::FilteredAddRow(std::vector<LivestatusRowValue>& rs, const Filter::Pt
                rval.GroupByType = groupByType;
                rval.GroupByObject = groupByObject;
 
-               rs.push_back(rval);
-
+               rs.emplace_back(std::move(rval));
        }
 
        return true;
index 576538524baecfb7b79c0343ea9698bfc6e162b7..20640898b1ae5df114342c9500c834c83e9ef2ec 100644 (file)
@@ -156,10 +156,10 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        Dictionary::Ptr envMacros = new Dictionary();
 
index 919e7fbedca82bac1f5b117fa5ea4cf8f6f159a7..80208b66d92d58e3034f767554cdd9f66712ec21 100644 (file)
@@ -52,10 +52,10 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(),
            NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
index 7f6b89a7cdfdcdd19f9adbc3a96c1c566031a573..652ef7e4a84e9490c5dabd6edb55eb75a8816b0a 100644 (file)
@@ -44,10 +44,10 @@ void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        int dummyState = MacroProcessor::ResolveMacros("$dummy_state$", resolvers, checkable->GetLastCheckResult(),
            NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
index d2953b0dda56cd61147b699c1a5853e7fc7bda3a..4507bd10a0e4f8f62459752aa92b6353fc1929b3 100644 (file)
@@ -46,10 +46,10 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
            resolvers, resolvedMacros, useResolvedMacros,
index 51308f55598e395db6f030c2f124358b550219e8..5944518966b1dd898cdf81cfcdcdfaa6127b1a34 100644 (file)
@@ -44,10 +44,10 @@ void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable,
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
            resolvers, resolvedMacros, useResolvedMacros,
index 3485c5c0fc3f9c36885bf873fd955266c3a33d96..b4ec80df2b7c053b2d9c960a08cc598c49bbbd2f 100644 (file)
@@ -55,14 +55,14 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
        tie(host, service) = GetHostService(checkable);
 
        MacroProcessor::ResolverList resolvers;
-       resolvers.push_back(std::make_pair("user", user));
-       resolvers.push_back(std::make_pair("notification", notificationExtra));
-       resolvers.push_back(std::make_pair("notification", notification));
+       resolvers.emplace_back("user", user);
+       resolvers.emplace_back("notification", notificationExtra);
+       resolvers.emplace_back("notification", notification);
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("command", commandObj));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("command", commandObj);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers,
            resolvedMacros, useResolvedMacros,
index ce648cd54b5971829395e801a4199df612c0776a..f113aef1345ff52658720048aef7bded6c79f8f0 100644 (file)
@@ -363,7 +363,7 @@ void ElasticsearchWriter::Enqueue(String type, const Dictionary::Ptr& fields, do
        Log(LogDebug, "ElasticsearchWriter")
            << "Add to fields to message list: '" << fieldsBody << "'.";
 
-       m_DataBuffer.push_back(indexBody + fieldsBody);
+       m_DataBuffer.emplace_back(indexBody + fieldsBody);
 
        /* Flush if we've buffered too much to prevent excessive memory use. */
        if (static_cast<int>(m_DataBuffer.size()) >= GetFlushThreshold()) {
@@ -412,10 +412,10 @@ void ElasticsearchWriter::SendRequest(const String& body)
        /* Specify the index path. Best practice is a daily rotation.
         * Example: http://localhost:9200/icinga2-2017.09.11?pretty=1
         */
-       path.push_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime()));
+       path.emplace_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime()));
 
        /* Use the bulk message format. */
-       path.push_back("_bulk");
+       path.emplace_back("_bulk");
 
        url->SetPath(path);
 
index 86611393cda0e1df3458a6a238f0bdb9430f7858..b871043586c91f1983a611802f47f6a206549b79 100644 (file)
@@ -199,9 +199,9 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String prefix;
 
index dc8e48955bd1cb9d2b5ae5cb8931d2a4c5d59efe..e9636645ce8f183a568312daf394eebb1f86a5ff 100644 (file)
@@ -194,9 +194,9 @@ void InfluxdbWriter::InternalCheckResultHandler(const Checkable::Ptr& checkable,
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String prefix;
 
index 3200252ff6b4764bd8b476004341ee91eafd8266..cb2da1150df361895d2914e2032205c451147d43 100644 (file)
@@ -100,9 +100,9 @@ void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
 
        MacroProcessor::ResolverList resolvers;
        if (service)
-               resolvers.push_back(std::make_pair("service", service));
-       resolvers.push_back(std::make_pair("host", host));
-       resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
+               resolvers.emplace_back("service", service);
+       resolvers.emplace_back("host", host);
+       resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        if (service) {
                String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, NULL, &PerfdataWriter::EscapeMacroMetric);
index b4cc25813548e4c55ffdd0cb77f5abb69ab48940..8e91669f5399fbb6d12d9d01981a2296e2e879e7 100644 (file)
@@ -87,7 +87,7 @@ void ApiClient::TypesHttpCompletionCallback(HttpRequest& request, HttpResponse&
                        type->Name = typeInfo->Get("name");
                        type->PluralName = typeInfo->Get("plural_name");
                        // TODO: attributes
-                       types.push_back(type);
+                       types.emplace_back(std::move(type));
                }
 
                callback(boost::exception_ptr(), types);
@@ -204,7 +204,7 @@ void ApiClient::ObjectsHttpCompletionCallback(HttpRequest& request,
                                                ApiObjectReference ref;
                                                ref.Name = refInfo->Get("name");
                                                ref.Type = refInfo->Get("type");
-                                               object->UsedBy.push_back(ref);
+                                               object->UsedBy.emplace_back(std::move(ref));
                                        }
                                }
 
index 4c3d4d06e01f9a75133e2e6919fbbb951217156a..6e964c921e8887eae6cd0a5825a4df3170a14d3d 100644 (file)
@@ -758,7 +758,7 @@ void ApiListener::ApiReconnectTimerHandler(void)
        std::vector<String> names;
        for (const Endpoint::Ptr& endpoint : ConfigType::GetObjectsByType<Endpoint>())
                if (endpoint->GetConnected())
-                       names.push_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
+                       names.emplace_back(endpoint->GetName() + " (" + Convert::ToString(endpoint->GetClients().size()) + ")");
 
        Log(LogNotice, "ApiListener")
            << "Connected endpoints: " << Utility::NaturalJoin(names);
index 61cf09139ef331754a2b2082127474bf0ac26759..4bcff35041d9a61465f8318c53b9ddff3ccbd518 100644 (file)
@@ -66,8 +66,7 @@ std::vector<String> ConfigPackageUtility::GetPackages(void)
 
 void ConfigPackageUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
 {
-       String name = Utility::BaseName(path);
-       dirs.push_back(name);
+       dirs.emplace_back(Utility::BaseName(path));
 }
 
 bool ConfigPackageUtility::PackageExists(const String& name)
@@ -279,7 +278,7 @@ void ConfigPackageUtility::CollectPaths(const String& path, std::vector<std::pai
                    << boost::errinfo_errno(errno)
                    << boost::errinfo_file_name(path));
 
-       paths.push_back(std::make_pair(path, S_ISDIR(statbuf.st_mode)));
+       paths.emplace_back(path, S_ISDIR(statbuf.st_mode));
 #else /* _WIN32 */
        struct _stat statbuf;
        int rc = _stat(path.CStr(), &statbuf);
@@ -289,7 +288,7 @@ void ConfigPackageUtility::CollectPaths(const String& path, std::vector<std::pai
                    << boost::errinfo_errno(errno)
                    << boost::errinfo_file_name(path));
 
-       paths.push_back(std::make_pair(path, ((statbuf.st_mode & S_IFMT) == S_IFDIR)));
+       paths.emplace_back(path, ((statbuf.st_mode & S_IFMT) == S_IFDIR));
 #endif /* _WIN32 */
 }
 
index b9895928d9f322f5607807cc259ccb35e3f2bd4d..24881284b60dcab76c5c70b92d5182b8bc4ab01e 100644 (file)
@@ -212,7 +212,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
                        if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName))
                                BOOST_THROW_EXCEPTION(ScriptError("Access denied to object '" + name + "' of type '" + type + "'"));
 
-                       result.push_back(target);
+                       result.emplace_back(std::move(target));
                }
 
                attr = provider->GetPluralName(type);
@@ -228,7 +228,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
                                        if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter, target, variableName))
                                                BOOST_THROW_EXCEPTION(ScriptError("Access denied to object '" + name + "' of type '" + type + "'"));
 
-                                       result.push_back(target);
+                                       result.emplace_back(std::move(target));
                                }
                        }
                }
index e730ff2fa530e8cfef66cb0fe43155107c77eeb3..8cb6bbfddc38517a2e2947ae798d484b9d017abf 100644 (file)
@@ -169,7 +169,7 @@ std::shared_ptr<HttpRequest> HttpClientConnection::NewRequest(void)
 void HttpClientConnection::SubmitRequest(const std::shared_ptr<HttpRequest>& request,
     const HttpCompletionCallback& callback)
 {
-       m_Requests.push_back(std::make_pair(request, callback));
+       m_Requests.emplace_back(request, callback);
        request->Finish();
 }
 
index 1273fe754643f43b92ce0180fdfab486d613b01d..f0dd1742631dede078ecb79fb382f278128a9867 100644 (file)
@@ -72,7 +72,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
 
                if (current_handlers) {
                        ObjectLock olock(current_handlers);
-                       for (const HttpHandler::Ptr current_handler : current_handlers) {
+                       for (const HttpHandler::Ptr& current_handler : current_handlers) {
                                handlers.push_back(current_handler);
                        }
                }
index 587b587479a90e7d868edb0de81a9217267c1094..5499d6d32cdfcf9e47ffd4924eae9360aa846e73 100644 (file)
@@ -57,7 +57,7 @@ void HttpResponse::SetStatus(int code, const String& message)
 
 void HttpResponse::AddHeader(const String& key, const String& value)
 {
-       m_Headers.push_back(key + ": " + value + "\r\n");
+       m_Headers.emplace_back(key + ": " + value + "\r\n");
 }
 
 void HttpResponse::FinishHeaders(void)
index ce8a6a1a3d9e8ced560d12bb76d037ec387ac23b..89de1341a5bd3da40973ce17215d2c1155cdd003 100644 (file)
@@ -62,7 +62,7 @@ bool InfoHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request,
                        if (hasFilter)
                                name += " (filtered)";
 
-                       permInfo.push_back(name);
+                       permInfo.emplace_back(std::move(name));
                }
        }
 
index 16a0dbd8864af20ad48f50ce7aead2482cfa61e7..2fe56d730bf1ebd5d22c7db7b64811c9300e3123 100644 (file)
@@ -212,8 +212,7 @@ void Url::AddQueryElement(const String& name, const String& value)
 {
        auto it = m_Query.find(name);
        if (it == m_Query.end()) {
-               m_Query[name] = std::vector<String>();
-               m_Query[name].push_back(value);
+               m_Query[name] = std::vector<String> { value };
        } else
                m_Query[name].push_back(value);
 }
@@ -363,9 +362,7 @@ bool Url::ParsePath(const String& path)
                if (!ValidateToken(token, ACPATHSEGMENT))
                        return false;
 
-               String decodedToken = Utility::UnescapeString(token);
-
-               m_Path.push_back(decodedToken);
+               m_Path.emplace_back(Utility::UnescapeString(token));
        }
 
        return true;
@@ -411,11 +408,9 @@ bool Url::ParseQuery(const String& query)
                auto it = m_Query.find(key);
 
                if (it == m_Query.end()) {
-                       m_Query[key] = std::vector<String>();
-                       m_Query[key].push_back(value);
+                       m_Query[key] = std::vector<String> { std::move(value) };
                } else
-                       m_Query[key].push_back(value);
-
+                       m_Query[key].emplace_back(std::move(value));
        }
 
        return true;