Make some types auto-reference to prevent copies

This commit is contained in:
Ian McInerney 2023-12-19 14:23:36 +00:00
parent de441d1e23
commit 5c334c147b
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ public:
void GetTriangle( int index, VECTOR2I& a, VECTOR2I& b, VECTOR2I& c ) const 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 ]; a = m_vertices[ tri.a ];
b = m_vertices[ tri.b ]; b = m_vertices[ tri.b ];
c = m_vertices[ tri.c ]; c = m_vertices[ tri.c ];

View File

@ -364,7 +364,7 @@ BOOST_FIXTURE_TEST_CASE( PNSHoleCollisions, PNS_TEST_FIXTURE )
dumpObstacles( obstacles ); dumpObstacles( obstacles );
BOOST_CHECK_EQUAL( obstacles.size(), 1 ); 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_head, v1 );
BOOST_CHECK_EQUAL( first.m_item, v2 ); 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 ); BOOST_CHECK_EQUAL( obstacles.size(), 1 );
auto iter = obstacles.begin(); 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_head, v1->Hole() );
BOOST_CHECK_EQUAL( first.m_item, v2->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 ); BOOST_CHECK_EQUAL( obstacles.size(), 2 );
auto iter = obstacles.begin(); 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... // There is no guarantee on what order the two collisions will be in...
BOOST_CHECK( ( first.m_head == v1 && first.m_item == v2->Hole() ) BOOST_CHECK( ( first.m_head == v1 && first.m_item == v2->Hole() )