cmPackageInfoReader: Just use std::string

Change cmPackageInfoReader::SetMetaProperty to just take the property
name as a std::string. We end up constructing one when we call
cmTarget::SetProperty, so we might as well do it up front and be done
with it. (Before, we were converting a string_view to char*, which is
decidedly non-optimal.)
This commit is contained in:
Matthew Woehlke
2025-11-03 13:14:25 -05:00
committed by Brad King
parent 6c2fc502b6
commit be99a82eee
2 changed files with 5 additions and 5 deletions

View File

@@ -646,13 +646,13 @@ void cmPackageInfoReader::SetImportProperty(cmTarget* target,
}
void cmPackageInfoReader::SetMetaProperty(
cmTarget* target, cm::string_view property, Json::Value const& value,
cmTarget* target, std::string const& property, Json::Value const& value,
std::string const& defaultValue) const
{
if (!value.isNull()) {
target->SetProperty(property.data(), value.asString());
target->SetProperty(property, value.asString());
} else if (!defaultValue.empty()) {
target->SetProperty(property.data(), defaultValue);
target->SetProperty(property, defaultValue);
}
}
@@ -734,7 +734,7 @@ void cmPackageInfoReader::SetTargetProperties(
// Add other information.
if (configuration.empty()) {
this->SetMetaProperty(target, "SPDX_LICENSE"_s, data["license"],
this->SetMetaProperty(target, "SPDX_LICENSE", data["license"],
this->DefaultLicense);
}
}

View File

@@ -100,7 +100,7 @@ private:
void SetImportProperty(cmTarget* target, cm::string_view property,
cm::string_view configuration,
Json::Value const& value) const;
void SetMetaProperty(cmTarget* target, cm::string_view property,
void SetMetaProperty(cmTarget* target, std::string const& property,
Json::Value const& value,
std::string const& defaultValue = {}) const;