From dcdb7442a49cd77fbf37df0b2fae5b20adc482a1 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Fri, 25 Mar 2022 07:56:30 +0100 Subject: [PATCH] Apply several clang-tidy fixes --- poly2tri/common/shapes.cc | 14 ++++++-------- poly2tri/sweep/advancing_front.cc | 2 +- poly2tri/sweep/sweep.cc | 5 ++--- poly2tri/sweep/sweep_context.cc | 12 ++++-------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/poly2tri/common/shapes.cc b/poly2tri/common/shapes.cc index ed82175..359ef75 100644 --- a/poly2tri/common/shapes.cc +++ b/poly2tri/common/shapes.cc @@ -86,13 +86,11 @@ void Triangle::MarkNeighbor(Triangle& t) void Triangle::Clear() { Triangle *t; - for( int i=0; i<3; i++ ) - { - t = neighbors_[i]; - if( t != nullptr ) - { - t->ClearNeighbor( this ); - } + for (auto& neighbor : neighbors_) { + t = neighbor; + if (t != nullptr) { + t->ClearNeighbor(this); + } } ClearNeighbors(); points_[0]=points_[1]=points_[2] = nullptr; @@ -410,4 +408,4 @@ bool IsDelaunay(const std::vector& triangles) return true; } -} +} // namespace p2t diff --git a/poly2tri/sweep/advancing_front.cc b/poly2tri/sweep/advancing_front.cc index b8e9609..e981bad 100644 --- a/poly2tri/sweep/advancing_front.cc +++ b/poly2tri/sweep/advancing_front.cc @@ -107,4 +107,4 @@ AdvancingFront::~AdvancingFront() { } -} +} // namespace p2t diff --git a/poly2tri/sweep/sweep.cc b/poly2tri/sweep/sweep.cc index 3267a41..3f35a21 100644 --- a/poly2tri/sweep/sweep.cc +++ b/poly2tri/sweep/sweep.cc @@ -815,10 +815,9 @@ void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& Sweep::~Sweep() { // Clean up memory - for(size_t i = 0; i < nodes_.size(); i++) { - delete nodes_[i]; + for (auto& node : nodes_) { + delete node; } - } } // namespace p2t diff --git a/poly2tri/sweep/sweep_context.cc b/poly2tri/sweep/sweep_context.cc index 79bc5e7..a486e18 100644 --- a/poly2tri/sweep/sweep_context.cc +++ b/poly2tri/sweep/sweep_context.cc @@ -194,17 +194,13 @@ SweepContext::~SweepContext() delete af_middle_; delete af_tail_; - typedef std::list type_list; - - for(type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) { - Triangle* ptr = *iter; - delete ptr; + for (auto ptr : map_) { + delete ptr; } - for(unsigned int i = 0; i < edge_list.size(); i++) { - delete edge_list[i]; + for (auto& i : edge_list) { + delete i; } - } } // namespace p2t