diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index 5042eb6b6..e05bce7b4 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -111,12 +111,14 @@ bool ApplyRule::IsValidTargetType(const String& sourceType, const String& target return false; } -std::vector ApplyRule::GetTargetTypes(const String& sourceType) +const std::vector& ApplyRule::GetTargetTypes(const String& sourceType) { auto it = m_Types.find(sourceType); - if (it == m_Types.end()) - return std::vector(); + if (it == m_Types.end()) { + static const std::vector noTypes; + return noTypes; + } return it->second; } diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 303b259e1..1d6e65a13 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -43,7 +43,7 @@ public: static void RegisterType(const String& sourceType, const std::vector& targetTypes); static bool IsValidSourceType(const String& sourceType); static bool IsValidTargetType(const String& sourceType, const String& targetType); - static std::vector GetTargetTypes(const String& sourceType); + static const std::vector& GetTargetTypes(const String& sourceType); static void CheckMatches(bool silent); diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 8fa10e71f..939681e68 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -1165,7 +1165,7 @@ apply: if (!ApplyRule::IsValidTargetType(type, target)) { if (target == "") { - std::vector types = ApplyRule::GetTargetTypes(type); + auto& types (ApplyRule::GetTargetTypes(type)); String typeNames; for (std::vector::size_type i = 0; i < types.size(); i++) {