diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp index 6bc8f5c549..9cba55d50c 100644 --- a/common/geometry/shape_poly_set.cpp +++ b/common/geometry/shape_poly_set.cpp @@ -2134,20 +2134,20 @@ bool SHAPE_POLY_SET::HasTouchingHoles() const bool SHAPE_POLY_SET::hasTouchingHoles( const POLYGON& aPoly ) const { - std::vector< VECTOR2I > pts; + std::set< long long > ptHashes; for( const auto& lc : aPoly ) { - for( int i = 0; i < lc.PointCount(); i++ ) + for( const VECTOR2I& pt : lc.CPoints() ) { - const auto p = lc.CPoint( i ); + const long long ptHash = (long long) pt.x << 32 | pt.y; - if( std::find( pts.begin(), pts.end(), p ) != pts.end() ) + if( ptHashes.count( ptHash ) > 0 ) { return true; } - pts.push_back( p ); + ptHashes.insert( ptHash ); } } diff --git a/include/geometry/shape_line_chain.h b/include/geometry/shape_line_chain.h index 094488c9c8..04e7e2708b 100644 --- a/include/geometry/shape_line_chain.h +++ b/include/geometry/shape_line_chain.h @@ -260,6 +260,11 @@ public: return m_points[aIndex]; } + const std::vector& CPoints() const + { + return m_points; + } + /** * Returns the last point in the line chain. */