From e04af1e9c234dab20a5c8eba84f04d0e0db18f49 Mon Sep 17 00:00:00 2001 From: Deniz Bahadir Date: Thu, 28 Mar 2024 14:16:10 +0100 Subject: [PATCH] cmGetSorceFilePropertyCommand: Simplify string comparisons --- Source/cmGetSourceFilePropertyCommand.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 40ae1126cf..17f84383ed 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -2,6 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGetSourceFilePropertyCommand.h" +#include +#include + #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSetPropertyCommand.h" @@ -23,11 +26,11 @@ bool cmGetSourceFilePropertyCommand(std::vector const& args, bool source_file_target_option_enabled = false; int property_arg_index = 2; - if (args[2] == "DIRECTORY" && args_size == 5) { + if (args[2] == "DIRECTORY"_s && args_size == 5) { property_arg_index = 4; source_file_directory_option_enabled = true; source_file_directories.push_back(args[3]); - } else if (args[2] == "TARGET_DIRECTORY" && args_size == 5) { + } else if (args[2] == "TARGET_DIRECTORY"_s && args_size == 5) { property_arg_index = 4; source_file_target_option_enabled = true; source_file_target_directories.push_back(args[3]); @@ -44,6 +47,7 @@ bool cmGetSourceFilePropertyCommand(std::vector const& args, } std::string const& var = args[0]; + std::string const& propName = args[property_arg_index]; bool source_file_paths_should_be_absolute = source_file_directory_option_enabled || source_file_target_option_enabled; std::string const file = @@ -53,14 +57,14 @@ bool cmGetSourceFilePropertyCommand(std::vector const& args, cmSourceFile* sf = mf.GetSource(file); // for the location we must create a source file first - if (!sf && args[property_arg_index] == "LOCATION") { + if (!sf && propName == "LOCATION"_s) { sf = mf.CreateSource(file); } if (sf) { cmValue prop = nullptr; - if (!args[property_arg_index].empty()) { - prop = sf->GetPropertyForUser(args[property_arg_index]); + if (!propName.empty()) { + prop = sf->GetPropertyForUser(propName); } if (prop) { // Set the value on the original Makefile scope, not the scope of the