From 5c334c147bb1f5c1dce0dec3f27db9a54196673f Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 19 Dec 2023 14:23:36 +0000 Subject: [PATCH] Make some types auto-reference to prevent copies --- libs/kimath/include/geometry/shape_poly_set.h | 2 +- qa/tests/pcbnew/test_pns_basics.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/kimath/include/geometry/shape_poly_set.h b/libs/kimath/include/geometry/shape_poly_set.h index 2192837918..a3665b58dc 100644 --- a/libs/kimath/include/geometry/shape_poly_set.h +++ b/libs/kimath/include/geometry/shape_poly_set.h @@ -138,7 +138,7 @@ public: void GetTriangle( int index, VECTOR2I& a, VECTOR2I& b, VECTOR2I& c ) const { - auto tri = m_triangles[ index ]; + auto& tri = m_triangles[ index ]; a = m_vertices[ tri.a ]; b = m_vertices[ tri.b ]; c = m_vertices[ tri.c ]; diff --git a/qa/tests/pcbnew/test_pns_basics.cpp b/qa/tests/pcbnew/test_pns_basics.cpp index 2d4e64dc84..40802406d0 100644 --- a/qa/tests/pcbnew/test_pns_basics.cpp +++ b/qa/tests/pcbnew/test_pns_basics.cpp @@ -364,7 +364,7 @@ BOOST_FIXTURE_TEST_CASE( PNSHoleCollisions, PNS_TEST_FIXTURE ) dumpObstacles( obstacles ); BOOST_CHECK_EQUAL( obstacles.size(), 1 ); - const auto first = *obstacles.begin(); + const auto& first = *obstacles.begin(); BOOST_CHECK_EQUAL( first.m_head, v1 ); BOOST_CHECK_EQUAL( first.m_item, v2 ); @@ -382,7 +382,7 @@ BOOST_FIXTURE_TEST_CASE( PNSHoleCollisions, PNS_TEST_FIXTURE ) BOOST_CHECK_EQUAL( obstacles.size(), 1 ); auto iter = obstacles.begin(); - const auto first = *iter++; + const auto& first = *iter++; BOOST_CHECK_EQUAL( first.m_head, v1->Hole() ); BOOST_CHECK_EQUAL( first.m_item, v2->Hole() ); @@ -400,7 +400,7 @@ BOOST_FIXTURE_TEST_CASE( PNSHoleCollisions, PNS_TEST_FIXTURE ) BOOST_CHECK_EQUAL( obstacles.size(), 2 ); auto iter = obstacles.begin(); - const auto first = *iter++; + const auto& first = *iter++; // There is no guarantee on what order the two collisions will be in... BOOST_CHECK( ( first.m_head == v1 && first.m_item == v2->Hole() )