Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create a flight plan copy when creating an optimization driver #3821

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ksp_plugin/flight_plan_optimization_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ namespace internal {
using std::placeholders::_1;

FlightPlanOptimizationDriver::FlightPlanOptimizationDriver(
FlightPlan const& flight_plan,
not_null<std::shared_ptr<FlightPlan>> const& flight_plan,
FlightPlanOptimizer::MetricFactory metric_factory)
: flight_plan_under_optimization_(flight_plan),
: flight_plan_under_optimization_(*flight_plan), // Copy.
flight_plan_optimizer_(&flight_plan_under_optimization_,
std::move(metric_factory),
[this](FlightPlan const& flight_plan) {
UpdateLastFlightPlan(flight_plan);
}),
last_flight_plan_(
make_not_null_shared<FlightPlan>(flight_plan_under_optimization_)) {}
last_flight_plan_(flight_plan) {}

FlightPlanOptimizationDriver::~FlightPlanOptimizationDriver() {
// Ensure that we do not have a thread still running with references to the
Expand Down
3 changes: 2 additions & 1 deletion ksp_plugin/flight_plan_optimization_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FlightPlanOptimizationDriver {
};

FlightPlanOptimizationDriver(
FlightPlan const& flight_plan,
not_null<std::shared_ptr<FlightPlan>> const& flight_plan,
FlightPlanOptimizer::MetricFactory metric_factory);

virtual ~FlightPlanOptimizationDriver();
Expand All @@ -54,6 +54,7 @@ class FlightPlanOptimizationDriver {
void Wait() const;

private:
// The progress callback of the optimizer.
void UpdateLastFlightPlan(FlightPlan const& flight_plan);

// The flight plan being optimized, asynchronously modified by the optimizer.
Expand Down
2 changes: 1 addition & 1 deletion ksp_plugin/vessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void Vessel::MakeFlightPlanOptimizationDriver(
optimization_driver->Interrupt();
}
optimization_driver = make_not_null_unique<FlightPlanOptimizationDriver>(
*flight_plan, std::move(metric_factory));
flight_plan, std::move(metric_factory));
}

void Vessel::StartFlightPlanOptimizationDriver(
Expand Down