mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	Only look up $point's X and Y once, rather than once on every pass through the loop.
(Those lookups are expensive)
This commit is contained in:
		
							parent
							
								
									3e8c5804fe
								
							
						
					
					
						commit
						da0e67a891
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -243,8 +243,12 @@ sub nearest_point_index { | |||
|     my ($point, $points) = @_; | ||||
|      | ||||
|     my ($nearest_point_index, $distance) = (); | ||||
| 
 | ||||
|     my $point_x = $point->[X]; | ||||
|     my $point_y = $point->[Y]; | ||||
| 
 | ||||
|     for my $i (0..$#$points) { | ||||
|         my $d = (($point->[X] - $points->[$i]->[X])**2) + (($point->[Y] - $points->[$i]->[Y])**2); | ||||
|         my $d = (($point_x - $points->[$i]->[X])**2) + (($point_y - $points->[$i]->[Y])**2); | ||||
|         if (!defined $distance || $d < $distance) { | ||||
|             $nearest_point_index = $i; | ||||
|             $distance = $d; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jesse Vincent
						Jesse Vincent