szaszm commented on code in PR #1543:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1543#discussion_r1163950530


##########
libminifi/src/Configuration.cpp:
##########
@@ -179,12 +179,10 @@ std::vector<std::string> 
Configuration::getSensitiveProperties(const std::functi
 }
 
 bool Configuration::validatePropertyValue(const std::string& property_name, 
const std::string& property_value) {
-  for (const auto& config_property: Configuration::CONFIGURATION_PROPERTIES) {
-    if (config_property.name == property_name) {
-      return config_property.validator->validate(property_name, 
property_value).valid();
-    }
-  }
-  return true;
+  if (!Configuration::CONFIGURATION_PROPERTIES.contains(property_name))
+    return true;
+
+  return 
Configuration::CONFIGURATION_PROPERTIES.at(property_name)->validate(property_name,
 property_value).valid();

Review Comment:
   We should do the lookup only once, not twice.
   ```suggestion
     const auto validator = 
Configuration::CONFIGURATION_PROPERTIES.find(property_name);
     if (validator == std::end(Configuration::CONFIGURATION_PROPERTIES))
       return true;
   
     return (*validator)->validate(property_name, property_value).valid();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to