mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
ApplyRule::GetTargetTypes(): return by const ref not to malloc()
This commit is contained in:
parent
cdd531445a
commit
7f50955674
@ -111,12 +111,14 @@ bool ApplyRule::IsValidTargetType(const String& sourceType, const String& target
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<String> ApplyRule::GetTargetTypes(const String& sourceType)
|
const std::vector<String>& ApplyRule::GetTargetTypes(const String& sourceType)
|
||||||
{
|
{
|
||||||
auto it = m_Types.find(sourceType);
|
auto it = m_Types.find(sourceType);
|
||||||
|
|
||||||
if (it == m_Types.end())
|
if (it == m_Types.end()) {
|
||||||
return std::vector<String>();
|
static const std::vector<String> noTypes;
|
||||||
|
return noTypes;
|
||||||
|
}
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
|
static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
|
||||||
static bool IsValidSourceType(const String& sourceType);
|
static bool IsValidSourceType(const String& sourceType);
|
||||||
static bool IsValidTargetType(const String& sourceType, const String& targetType);
|
static bool IsValidTargetType(const String& sourceType, const String& targetType);
|
||||||
static std::vector<String> GetTargetTypes(const String& sourceType);
|
static const std::vector<String>& GetTargetTypes(const String& sourceType);
|
||||||
|
|
||||||
static void CheckMatches(bool silent);
|
static void CheckMatches(bool silent);
|
||||||
|
|
||||||
|
@ -1165,7 +1165,7 @@ apply:
|
|||||||
|
|
||||||
if (!ApplyRule::IsValidTargetType(type, target)) {
|
if (!ApplyRule::IsValidTargetType(type, target)) {
|
||||||
if (target == "") {
|
if (target == "") {
|
||||||
std::vector<String> types = ApplyRule::GetTargetTypes(type);
|
auto& types (ApplyRule::GetTargetTypes(type));
|
||||||
String typeNames;
|
String typeNames;
|
||||||
|
|
||||||
for (std::vector<String>::size_type i = 0; i < types.size(); i++) {
|
for (std::vector<String>::size_type i = 0; i < types.size(); i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user