Slightly optimize SEG::NearestPoint.

This commit is contained in:
Alex Shvartzkop 2024-06-20 04:01:19 +03:00
parent 62fb5697b4
commit ec271c20db
1 changed files with 3 additions and 2 deletions

View File

@ -268,8 +268,9 @@ bool SEG::Contains( const VECTOR2I& aP ) const
const VECTOR2I SEG::NearestPoint( const VECTOR2I& aP ) const const VECTOR2I SEG::NearestPoint( const VECTOR2I& aP ) const
{ {
VECTOR2I d = B - A; // Inlined for performance reasons
ecoord l_squared = d.Dot( d ); VECTOR2L d( B.x - A.x, B.y - A.y );
ecoord l_squared( d.x * d.x + d.y * d.y );
if( l_squared == 0 ) if( l_squared == 0 )
return A; return A;