refactor(eval/builtins/intersectAttrs): use cmp for three-way comparison
There is no point in separately checking lt/eq/gt separately when we always need the full ordering anyway. Change-Id: I993108029d205ac17f01acdb6dbf9b2f0cd80f28 Reviewed-on: https://cl.snix.dev/c/snix/+/30372 Reviewed-by: Florian Klink <flokli@flokli.de> Tested-by: besadii
This commit is contained in:
		
							parent
							
								
									3d95109328
								
							
						
					
					
						commit
						bcb8438856
					
				
					 1 changed files with 24 additions and 28 deletions
				
			
		|  | @ -811,36 +811,32 @@ mod pure_builtins { | |||
|         // We opted for this implementation over simpler ones because of the
 | ||||
|         // heavy use of this function in nixpkgs.
 | ||||
|         loop { | ||||
|             if left.0 == right.0 { | ||||
|                 out.insert(right.0.clone(), right.1.clone()); | ||||
|             match left.0.cmp(right.0) { | ||||
|                 Ordering::Equal => { | ||||
|                     out.insert(right.0.clone(), right.1.clone()); | ||||
| 
 | ||||
|                 left = match left_iter.next() { | ||||
|                     Some(x) => x, | ||||
|                     None => break, | ||||
|                 }; | ||||
|                     left = match left_iter.next() { | ||||
|                         Some(x) => x, | ||||
|                         None => break, | ||||
|                     }; | ||||
| 
 | ||||
|                 right = match right_iter.next() { | ||||
|                     Some(x) => x, | ||||
|                     None => break, | ||||
|                 }; | ||||
| 
 | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             if left.0 < right.0 { | ||||
|                 left = match left_iter.next() { | ||||
|                     Some(x) => x, | ||||
|                     None => break, | ||||
|                 }; | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
|             if right.0 < left.0 { | ||||
|                 right = match right_iter.next() { | ||||
|                     Some(x) => x, | ||||
|                     None => break, | ||||
|                 }; | ||||
|                 continue; | ||||
|                     right = match right_iter.next() { | ||||
|                         Some(x) => x, | ||||
|                         None => break, | ||||
|                     }; | ||||
|                 } | ||||
|                 Ordering::Less => { | ||||
|                     left = match left_iter.next() { | ||||
|                         Some(x) => x, | ||||
|                         None => break, | ||||
|                     }; | ||||
|                 } | ||||
|                 Ordering::Greater => { | ||||
|                     right = match right_iter.next() { | ||||
|                         Some(x) => x, | ||||
|                         None => break, | ||||
|                     }; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue