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

This commit is contained in:
Robert Schumacher 2018-01-22 23:40:41 -08:00
parent 77eae92e75
commit 0682bb734d
4 changed files with 6 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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