Performance improvement for SHAPE_LINE_CHANGE::PointInside().

It was calculating the bounding box twice (and failing to honour
the accuracy parameter on the bounding box test).

Worse, constructing the bounding box is about the same speed as
the rigorous test, so it never improves things.
This commit is contained in:
Jeff Young 2019-06-22 16:48:20 +01:00
parent 70e6d95c7f
commit 1099befab1
1 changed files with 5 additions and 3 deletions

View File

@ -351,10 +351,12 @@ int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const
bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aPt, int aAccuracy ) const
{
BOX2I bbox = BBox();
bbox.Inflate( aAccuracy );
/*
* Don't check the bounding box. Building it is about the same speed as the rigorous
* test below and so just slows things down by doing potentially two tests.
*/
if( !m_closed || PointCount() < 3 || !BBox().Contains( aPt ) )
if( !m_closed || PointCount() < 3 )
return false;
bool inside = false;