Move insert call out of variable scope

This commit is contained in:
Filip Sykala - NTB T15p 2023-01-27 15:27:01 +01:00
parent 8cb414c262
commit 4e56f75541

View file

@ -115,7 +115,10 @@ void remove_spikes(ExPolygons &expolygons, const SpikeDesc &spike_desc);
};
bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &spike_desc) {
std::optional<Point> add;
Points &pts = polygon.points;
{
size_t pts_size = pts.size();
if (pts_size < 3)
return false;
@ -177,15 +180,17 @@ bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &sp
} else {
// move point B on C-side and add point on A-side(left - before)
pts[index] = c_side();
Point add = a_side();
add = a_side();
if (add == pts[index]) {
// should be very rare, when SpikeDesc has small base
// will be fixed by remove B point
pts.erase(pts.begin() + index);
return true;
}
pts.insert(pts.begin() + index, add);
}
}
if (add.has_value())
pts.insert(pts.begin() + index, *add);
return false;
}