diff --git a/poly2tri/sweep/sweep.cc b/poly2tri/sweep/sweep.cc index 3f35a21..4f02115 100644 --- a/poly2tri/sweep/sweep.cc +++ b/poly2tri/sweep/sweep.cc @@ -54,8 +54,8 @@ void Sweep::SweepPoints(SweepContext& tcx) for (size_t i = 1; i < tcx.point_count(); i++) { Point& point = *tcx.GetPoint(i); Node* node = &PointEvent(tcx, point); - for (unsigned int j = 0; j < point.edge_list.size(); j++) { - EdgeEvent(tcx, point.edge_list[j], node); + for (auto& j : point.edge_list) { + EdgeEvent(tcx, j, node); } } } diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index a486e18..7b9432f 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -1,5 +1,5 @@ /* - * Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors + * Poly2Tri Copyright (c) 2009-2022, Poly2Tri Contributors * https://github.com/jhasse/poly2tri * * All rights reserved. @@ -34,7 +34,7 @@ namespace p2t { -SweepContext::SweepContext(const std::vector& polyline) : points_(polyline), +SweepContext::SweepContext(std::vector polyline) : points_(std::move(polyline)), front_(nullptr), head_(nullptr), tail_(nullptr), @@ -48,8 +48,8 @@ SweepContext::SweepContext(const std::vector& polyline) : points_(polyli void SweepContext::AddHole(const std::vector& polyline) { InitEdges(polyline); - for(unsigned int i = 0; i < polyline.size(); i++) { - points_.push_back(polyline[i]); + for (auto i : polyline) { + points_.push_back(i); } } @@ -73,8 +73,8 @@ void SweepContext::InitTriangulation() double ymax(points_[0]->y), ymin(points_[0]->y); // Calculate bounds. - for (unsigned int i = 0; i < points_.size(); i++) { - Point& p = *points_[i]; + for (auto& point : points_) { + Point& p = *point; if (p.x > xmax) xmax = p.x; if (p.x < xmin) diff --git a/poly2tri/sweep/sweep_context.h b/poly2tri/sweep/sweep_context.h index 47d970b..da62181 100644 --- a/poly2tri/sweep/sweep_context.h +++ b/poly2tri/sweep/sweep_context.h @@ -1,5 +1,5 @@ /* - * Poly2Tri Copyright (c) 2009-2018, Poly2Tri Contributors + * Poly2Tri Copyright (c) 2009-2022, Poly2Tri Contributors * https://github.com/jhasse/poly2tri * * All rights reserved. @@ -52,7 +52,7 @@ class SweepContext { public: /// Constructor -SweepContext(const std::vector& polyline); +explicit SweepContext(std::vector polyline); /// Destructor ~SweepContext(); @@ -103,15 +103,16 @@ struct Basin { double width; bool left_highest; - Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false) + Basin() + : left_node(nullptr), bottom_node(nullptr), right_node(nullptr), width(0.0), left_highest(false) { } void Clear() { - left_node = NULL; - bottom_node = NULL; - right_node = NULL; + left_node = nullptr; + bottom_node = nullptr; + right_node = nullptr; width = 0.0; left_highest = false; }