mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-18 14:32:36 +00:00
build: clear 50 warnings - pessimizing moves and null checks that cannot fail (#15408)
* build: remove std::move that blocks copy elision std::move wrapped around a temporary, or around a local being returned, stops the compiler constructing it in place. Each edit is the fix clang suggests, which is to delete the std::move call and keep its argument. Three of the 39 sites save a move, the two return std::move(local) in Print.cpp and TreeSupport.cpp:2749. The rest are equivalent either way and match how the codebase already writes this elsewhere. Clears 39 -Wpessimizing-move warnings. * build: drop null checks on references and this A reference cannot be bound to null and this cannot be null, so the compiler folds these conditions to true and drops the guard. Seven are if (&bitmap && bitmap.IsOk()), where IsOk() already does the work; two test this directly. The guarded code runs either way, so removing the dead operand changes nothing. Clears 11 -Wundefined-bool-conversion warnings.
This commit is contained in:
@@ -842,7 +842,7 @@ void TreeSupport::detect_overhangs(bool check_support_necessity/* = false*/)
|
||||
|
||||
// normal overhang
|
||||
ExPolygons lower_layer_offseted = offset_ex(lower_polys, support_offset_scaled, SUPPORT_SURFACES_OFFSET_PARAMETERS);
|
||||
overhangs_all_layers[layer_nr] = std::move(diff_ex(curr_polys, lower_layer_offseted));
|
||||
overhangs_all_layers[layer_nr] = diff_ex(curr_polys, lower_layer_offseted);
|
||||
|
||||
double duration{ std::chrono::duration_cast<second_>(clock_::now() - t0).count() };
|
||||
if (duration > 30 || overhangs_all_layers[layer_nr].size() > 100) {
|
||||
@@ -1396,7 +1396,7 @@ void TreeSupport::generate_toolpaths()
|
||||
raft_areas.push_back(expoly);
|
||||
}
|
||||
|
||||
raft_areas = std::move(offset_ex(raft_areas, scale_(object_config.raft_first_layer_expansion)));
|
||||
raft_areas = offset_ex(raft_areas, scale_(object_config.raft_first_layer_expansion));
|
||||
|
||||
size_t layer_nr = 0;
|
||||
for (; layer_nr < m_slicing_params.base_raft_layers; layer_nr++) {
|
||||
@@ -1522,9 +1522,9 @@ void TreeSupport::generate_toolpaths()
|
||||
erSupportMaterialInterface : erSupportMaterial;
|
||||
make_perimeter_and_inner_brim(ts_layer->support_fills.entities, poly, wall_count, flow,
|
||||
brim_role);
|
||||
polys = std::move(offset_ex(poly, -flow.scaled_spacing()));
|
||||
polys = offset_ex(poly, -flow.scaled_spacing());
|
||||
} else if (area_group.type == SupportLayer::Roof1stLayer) {
|
||||
polys = std::move(offset_ex(poly, 0.5*support_flow.scaled_width()));
|
||||
polys = offset_ex(poly, 0.5*support_flow.scaled_width());
|
||||
}
|
||||
else {
|
||||
polys.push_back(poly);
|
||||
@@ -2269,7 +2269,7 @@ void TreeSupport::draw_circles()
|
||||
// Inside the gap: remove only the part overlapping the contact surface, keep the rest.
|
||||
if (bottom_gap_height > EPSILON && layer_bottom_z < band_gap_top - EPSILON) {
|
||||
any_gap_cleared = true;
|
||||
comp_poly = std::move(diff_ex(comp_poly, band.surfaces));
|
||||
comp_poly = diff_ex(comp_poly, band.surfaces);
|
||||
}
|
||||
|
||||
// Overlaps interface band
|
||||
@@ -2304,7 +2304,7 @@ void TreeSupport::draw_circles()
|
||||
ExPolygons comp_interface = band_ex.empty() ? ExPolygons {} : intersection_ex(comp_poly, band_ex);
|
||||
if (!comp_interface.empty()) {
|
||||
append(new_floor_areas, comp_interface);
|
||||
comp_poly = std::move(diff_ex(comp_poly, offset_ex(comp_interface, 10)));
|
||||
comp_poly = diff_ex(comp_poly, offset_ex(comp_interface, 10));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2396,7 +2396,7 @@ void TreeSupport::draw_circles()
|
||||
ts_layer->lslices.emplace_back(*expoly);
|
||||
}
|
||||
|
||||
ts_layer->lslices = std::move(union_ex(ts_layer->lslices));
|
||||
ts_layer->lslices = union_ex(ts_layer->lslices);
|
||||
//Must update bounding box which is used in avoid crossing perimeter
|
||||
ts_layer->lslices_bboxes.clear();
|
||||
ts_layer->lslices_bboxes.reserve(ts_layer->lslices.size());
|
||||
@@ -2474,7 +2474,7 @@ void TreeSupport::draw_circles()
|
||||
if (global_lightning_infill)
|
||||
{
|
||||
//search overhangs globally
|
||||
overhang = std::move(diff_ex(offset_ex(base_areas_lower, -2.0 * scale_(support_extrusion_width)), base_areas));
|
||||
overhang = diff_ex(offset_ex(base_areas_lower, -2.0 * scale_(support_extrusion_width)), base_areas);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2485,13 +2485,13 @@ void TreeSupport::draw_circles()
|
||||
Polygon rev_hole = hole;
|
||||
rev_hole.make_counter_clockwise();
|
||||
ExPolygons ex_hole;
|
||||
ex_hole.emplace_back(std::move(ExPolygon(rev_hole)));
|
||||
ex_hole.emplace_back(ExPolygon(rev_hole));
|
||||
for (auto& other_area : base_areas)
|
||||
//if (&other_area != &base_area)
|
||||
ex_hole = std::move(diff_ex(ex_hole, other_area));
|
||||
overhang = std::move(union_ex(overhang, ex_hole));
|
||||
ex_hole = diff_ex(ex_hole, other_area);
|
||||
overhang = union_ex(overhang, ex_hole);
|
||||
}
|
||||
overhang = std::move(intersection_ex(overhang, offset_ex(base_areas_lower, -0.5 * scale_(support_extrusion_width))));
|
||||
overhang = intersection_ex(overhang, offset_ex(base_areas_lower, -0.5 * scale_(support_extrusion_width)));
|
||||
}
|
||||
|
||||
overhangs.emplace_back(to_polygons(overhang));
|
||||
@@ -2746,7 +2746,7 @@ void TreeSupport::drop_nodes()
|
||||
|
||||
m_object->print()->set_status(60 + int(10 * (1 - float(layer_nr) / contact_nodes.size())), _u8L("Generating support"));// (boost::format(_u8L("Support: propagate branches at layer %d")) % layer_nr).str());
|
||||
|
||||
Polygons layer_contours = std::move(m_ts_data->get_contours_with_holes(obj_layer_nr));
|
||||
Polygons layer_contours = m_ts_data->get_contours_with_holes(obj_layer_nr);
|
||||
//std::unordered_map<Line, bool, LineHash>& mst_line_x_layer_contour_cache = m_mst_line_x_layer_contour_caches[layer_nr];
|
||||
tbb::concurrent_unordered_map<Line, bool, LineHash> mst_line_x_layer_contour_cache;
|
||||
auto is_line_cut_by_contour = [&mst_line_x_layer_contour_cache,&layer_contours](Point a, Point b)
|
||||
@@ -3763,7 +3763,7 @@ const ExPolygons& TreeSupportData::calculate_avoidance(const RadiusLayerPair& ke
|
||||
}
|
||||
const ExPolygons &collision = get_collision(radius, layer_nr);
|
||||
avoidance_areas.insert(avoidance_areas.end(), collision.begin(), collision.end());
|
||||
avoidance_areas = std::move(union_ex(avoidance_areas));
|
||||
avoidance_areas = union_ex(avoidance_areas);
|
||||
auto ret = m_avoidance_cache.insert({key, std::move(avoidance_areas)});
|
||||
//assert(ret.second);
|
||||
return ret.first->second;
|
||||
|
||||
Reference in New Issue
Block a user