Fix bug ShortestPath.cpp (#13331) (#7615)

Accessing a moved object.
Also this method create an unused "out" variable by removing from the parameter.
I guess It should update the parameter object?
Anyway, seems very wrong

(cherry picked from commit 534792e249da3efb83a62279f532b6690d028592)

Co-authored-by: Merill <merill@free.fr>
This commit is contained in:
Noisyfox 2024-11-30 21:38:59 +08:00 committed by GitHub
parent 89cf7f87bf
commit 4f9e946dfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1910,14 +1910,15 @@ static inline void improve_ordering_by_two_exchanges_with_segment_flipping(Polyl
for (const FlipEdge &edge : edges) {
Polyline &pl = polylines[edge.source_index];
out.emplace_back(std::move(pl));
if (edge.p2 == pl.first_point().cast<double>()) {
if (edge.p2 == out.back().first_point().cast<double>()) {
// Polyline is flipped.
out.back().reverse();
} else {
// Polyline is not flipped.
assert(edge.p1 == pl.first_point().cast<double>());
assert(edge.p1 == out.back().first_point().cast<double>());
}
}
polylines = out;
#ifndef NDEBUG
double cost_final = cost();