Просмотр исходного кода

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.)
Matthew Woehlke 2 месяцев назад
Родитель
Сommit
be99a82eee
2 измененных файлов с 5 добавлено и 5 удалено
  1. 4 4
      Source/cmPackageInfoReader.cxx
  2. 1 1
      Source/cmPackageInfoReader.h

+ 4 - 4
Source/cmPackageInfoReader.cxx

@@ -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);
   }
 }

+ 1 - 1
Source/cmPackageInfoReader.h

@@ -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;