[vcpkg] Store Optional<&> instead of Optional<*>
MODIFY
include/vcpkg/dependencies.h
include/vcpkg/dependencies.h
@@ -29,7 +29,7 @@ namespace vcpkg::Dependencies
Optional<StatusParagraph> status_paragraph;
Optional<BinaryControlFile> binary_control_file;
- Optional<const SourceControlFile*> source_control_file;
+ Optional<const SourceControlFile&> source_control_file;
};
}

MODIFY
src/tests.plan.cpp
src/tests.plan.cpp
@@ -41,8 +41,7 @@ namespace UnitTest1
Assert::AreEqual(plan.spec.triplet().to_string().c_str(), triplet.to_string().c_str());
- Assert::AreEqual(pkg_name.c_str(),
- (*plan.any_paragraph.source_control_file.get())->core_paragraph->name.c_str());
+ Assert::AreEqual(pkg_name.c_str(), plan.any_paragraph.source_control_file.get()->core_paragraph->name.c_str());
Assert::AreEqual(size_t(vec.size()), feature_list.size());
for (auto&& feature_name : vec)

MODIFY
src/vcpkg/dependencies.cpp
src/vcpkg/dependencies.cpp
@@ -117,7 +117,7 @@ namespace vcpkg::Dependencies
return PackageSpec::from_dependencies_of_port(p->core_paragraph.spec.name(), deps, triplet);
}
- if (const auto p = this->source_control_file.value_or(nullptr))
+ if (const auto p = this->source_control_file.get())
{
return PackageSpec::from_dependencies_of_port(
p->core_paragraph->name, filter_dependencies(p->core_paragraph->depends, triplet), triplet);
@@ -159,7 +159,7 @@ namespace vcpkg::Dependencies
const RequestType& request_type)
: spec(spec), plan_type(InstallPlanType::BUILD_AND_INSTALL), request_type(request_type), feature_list(features)
{
- this->any_paragraph.source_control_file = &any_paragraph;
+ this->any_paragraph.source_control_file = any_paragraph;
}
InstallPlanAction::InstallPlanAction(const PackageSpec& spec,
@@ -418,7 +418,7 @@ namespace vcpkg::Dependencies
return ExportPlanAction{spec, AnyParagraph{nullopt, std::move(*bcf), nullopt}, request_type};
auto maybe_scf = provider.get_control_file(spec.name());
- if (auto scf = maybe_scf.get()) return ExportPlanAction{spec, {nullopt, nullopt, scf}, request_type};
+ if (auto scf = maybe_scf.get()) return ExportPlanAction{spec, {nullopt, nullopt, *scf}, request_type};
Checks::exit_with_message(VCPKG_LINE_INFO, "Could not find package %s", spec);
}

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -293,7 +293,7 @@ namespace vcpkg::Install
auto result = [&]() -> Build::ExtendedBuildResult {
const Build::BuildPackageConfig build_config{
- *action.any_paragraph.source_control_file.value_or_exit(VCPKG_LINE_INFO),
+ action.any_paragraph.source_control_file.value_or_exit(VCPKG_LINE_INFO),
action.spec.triplet(),
paths.port_dir(action.spec),
action.build_options,

[vcpkg] Store Optional<&> instead of Optional<*>