binary-search: use nth-unsafe for a further performance gain
							parent
							
								
									eb3c6f414b
								
							
						
					
					
						commit
						cf69c58eee
					
				| 
						 | 
					@ -1,14 +1,14 @@
 | 
				
			||||||
! Copyright (C) 2008, 2010 Slava Pestov.
 | 
					! Copyright (C) 2008, 2010 Slava Pestov.
 | 
				
			||||||
! See http://factorcode.org/license.txt for BSD license.
 | 
					! See http://factorcode.org/license.txt for BSD license.
 | 
				
			||||||
USING: accessors arrays combinators hints kernel locals math
 | 
					USING: accessors arrays combinators hints kernel locals math
 | 
				
			||||||
math.order sequences ;
 | 
					math.order sequences sequences.private ;
 | 
				
			||||||
IN: binary-search
 | 
					IN: binary-search
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<PRIVATE
 | 
					<PRIVATE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
:: (search) ( seq from to quot: ( elt -- <=> ) -- i elt )
 | 
					:: (search) ( seq from to quot: ( elt -- <=> ) -- i elt )
 | 
				
			||||||
    from to + 2/ :> midpoint@
 | 
					    from to + 2/ :> midpoint@
 | 
				
			||||||
    midpoint@ seq nth :> midpoint
 | 
					    midpoint@ seq nth-unsafe :> midpoint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    to from - 1 <= [
 | 
					    to from - 1 <= [
 | 
				
			||||||
        midpoint@ midpoint
 | 
					        midpoint@ midpoint
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue