Skip to content

Commit

Permalink
Pass shared pointers, per preference, by reference.
Browse files Browse the repository at this point in the history
Otherwise they're passed by value. Not as bad as passing the entire _original_ object of course, but a ref is still a little lighter weight than a shared pointer object.

done as part of, but not nescesary for, CURA-11019
  • Loading branch information
rburema committed Sep 14, 2023
1 parent aa60cdd commit 4aa7391
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions include/SkeletalTrapezoidationEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SkeletalTrapezoidationEdge
{
return transitions.use_count() > 0 && (ignore_empty || ! transitions.lock()->empty());
}
void setTransitions(std::shared_ptr<std::list<TransitionMiddle>> storage)
void setTransitions(std::shared_ptr<std::list<TransitionMiddle>>& storage)
{
transitions = storage;
}
Expand All @@ -93,7 +93,7 @@ class SkeletalTrapezoidationEdge
{
return transition_ends.use_count() > 0 && (ignore_empty || ! transition_ends.lock()->empty());
}
void setTransitionEnds(std::shared_ptr<std::list<TransitionEnd>> storage)
void setTransitionEnds(std::shared_ptr<std::list<TransitionEnd>>& storage)
{
transition_ends = storage;
}
Expand All @@ -106,7 +106,7 @@ class SkeletalTrapezoidationEdge
{
return extrusion_junctions.use_count() > 0 && (ignore_empty || ! extrusion_junctions.lock()->empty());
}
void setExtrusionJunctions(std::shared_ptr<LineJunctions> storage)
void setExtrusionJunctions(std::shared_ptr<LineJunctions>& storage)
{
extrusion_junctions = storage;
}
Expand Down
2 changes: 1 addition & 1 deletion include/SkeletalTrapezoidationJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SkeletalTrapezoidationJoint
{
return beading.use_count() > 0;
}
void setBeading(std::shared_ptr<BeadingPropagation> storage)
void setBeading(std::shared_ptr<BeadingPropagation>& storage)
{
beading = storage;
}
Expand Down
10 changes: 5 additions & 5 deletions include/infill.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ class Infill
const Settings& settings,
int layer_idx,
SectionType section_type,
const std::shared_ptr<SierpinskiFillProvider> cross_fill_provider = nullptr,
const std::shared_ptr<LightningLayer> lightning_layer = nullptr,
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_provider = nullptr,
const std::shared_ptr<LightningLayer>& lightning_layer = nullptr,
const SliceMeshStorage* mesh = nullptr,
const Polygons& prevent_small_exposed_to_air = Polygons(),
const bool is_bridge_skin = false);
Expand Down Expand Up @@ -242,8 +242,8 @@ class Infill
Polygons& result_polygons,
Polygons& result_lines,
const Settings& settings,
const std::shared_ptr<SierpinskiFillProvider> cross_fill_pattern = nullptr,
const std::shared_ptr<LightningLayer> lightning_layer = nullptr,
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_pattern = nullptr,
const std::shared_ptr<LightningLayer>& lightning_layer = nullptr,
const SliceMeshStorage* mesh = nullptr);

/*!
Expand Down Expand Up @@ -402,7 +402,7 @@ class Infill
* see https://hal.archives-ouvertes.fr/hal-02155929/document
* \param result (output) The resulting polygons
*/
void generateLightningInfill(const std::shared_ptr<LightningLayer> lightning_layer, Polygons& result_lines);
void generateLightningInfill(const std::shared_ptr<LightningLayer>& lightning_layer, Polygons& result_lines);

/*!
* Generate sparse concentric infill
Expand Down
2 changes: 1 addition & 1 deletion src/communication/ArcusCommunication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void ArcusCommunication::sendOptimizedLayerData()
}
spdlog::info("Sending {} layers.", data.current_layer_count);

for (std::pair<const int, std::shared_ptr<proto::LayerOptimized>> entry : data.slice_data) // Note: This is in no particular order!
for (const auto& entry : data.slice_data) // Note: This is in no particular order!
{
spdlog::debug("Sending layer data for layer {} of {}.", entry.first, data.slice_data.size());
private_data->socket->sendMessage(entry.second); // Send the actual layers.
Expand Down
10 changes: 5 additions & 5 deletions src/infill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void Infill::generate(
const Settings& settings,
int layer_idx,
SectionType section_type,
const std::shared_ptr<SierpinskiFillProvider> cross_fill_provider,
const std::shared_ptr<LightningLayer> lightning_trees,
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_provider,
const std::shared_ptr<LightningLayer>& lightning_trees,
const SliceMeshStorage* mesh,
const Polygons& prevent_small_exposed_to_air,
const bool is_bridge_skin)
Expand Down Expand Up @@ -255,8 +255,8 @@ void Infill::_generate(
Polygons& result_polygons,
Polygons& result_lines,
const Settings& settings,
const std::shared_ptr<SierpinskiFillProvider> cross_fill_provider,
const std::shared_ptr<LightningLayer> lightning_trees,
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_provider,
const std::shared_ptr<LightningLayer>& lightning_trees,
const SliceMeshStorage* mesh)
{
if (inner_contour.empty())
Expand Down Expand Up @@ -432,7 +432,7 @@ void Infill::generateGyroidInfill(Polygons& result_lines, Polygons& result_polyg
PolylineStitcher<Polygons, Polygon, Point>::stitch(line_segments, result_lines, result_polygons, infill_line_width);
}

void Infill::generateLightningInfill(const std::shared_ptr<LightningLayer> trees, Polygons& result_lines)
void Infill::generateLightningInfill(const std::shared_ptr<LightningLayer>& trees, Polygons& result_lines)
{
// Don't need to support areas smaller than line width, as they are always within radius:
if (std::abs(inner_contour.area()) < infill_line_width || ! trees)
Expand Down

0 comments on commit 4aa7391

Please sign in to comment.