mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
ApplyRule::GetTargetTypes(): return by const ref not to malloc()
This commit is contained in:
parent
ce1a122618
commit
90fe4e5bea
@ -111,12 +111,14 @@ bool ApplyRule::IsValidTargetType(const String& sourceType, const String& target
|
||||
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);
|
||||
|
||||
if (it == m_Types.end())
|
||||
return std::vector<String>();
|
||||
if (it == m_Types.end()) {
|
||||
static const std::vector<String> noTypes;
|
||||
return noTypes;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
|
||||
static bool IsValidSourceType(const String& sourceType);
|
||||
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);
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ apply:
|
||||
|
||||
if (!ApplyRule::IsValidTargetType(type, target)) {
|
||||
if (target == "") {
|
||||
std::vector<String> types = ApplyRule::GetTargetTypes(type);
|
||||
auto& types (ApplyRule::GetTargetTypes(type));
|
||||
String typeNames;
|
||||
|
||||
for (std::vector<String>::size_type i = 0; i < types.size(); i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user