From 72da23725ad76453d4fac54de236f0d0baa7c2bb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 22 Sep 2019 20:44:43 -0700 Subject: [PATCH] pcbnew: Don't copy const structures when not needed Copying the const pointer on large structures (filled zones) will be very slow and memory intensive. This can cause OOM on linux and extreme slowdowns when the save is triggered. Fixes: lp:1840168 * https://bugs.launchpad.net/kicad/+bug/1840168 --- include/geometry/shape_poly_set.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/geometry/shape_poly_set.h b/include/geometry/shape_poly_set.h index 3f7382e4ea..f8e15a865f 100644 --- a/include/geometry/shape_poly_set.h +++ b/include/geometry/shape_poly_set.h @@ -171,7 +171,7 @@ class SHAPE_POLY_SET : public SHAPE if( m_currentPolygon != m_poly->OutlineCount() - 1 ) return false; - auto currentPolygon = m_poly->CPolygon( m_currentPolygon ); + const auto& currentPolygon = m_poly->CPolygon( m_currentPolygon ); return m_currentContour < (int) currentPolygon.size() - 1 || m_currentVertex < currentPolygon[m_currentContour].PointCount();