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
|
// We opted for this implementation over simpler ones because of the
|
||||||
// heavy use of this function in nixpkgs.
|
// heavy use of this function in nixpkgs.
|
||||||
loop {
|
loop {
|
||||||
if left.0 == right.0 {
|
match left.0.cmp(right.0) {
|
||||||
out.insert(right.0.clone(), right.1.clone());
|
Ordering::Equal => {
|
||||||
|
out.insert(right.0.clone(), right.1.clone());
|
||||||
|
|
||||||
left = match left_iter.next() {
|
left = match left_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => break,
|
None => break,
|
||||||
};
|
};
|
||||||
|
|
||||||
right = match right_iter.next() {
|
right = match right_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => break,
|
None => break,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
continue;
|
Ordering::Less => {
|
||||||
}
|
left = match left_iter.next() {
|
||||||
|
Some(x) => x,
|
||||||
if left.0 < right.0 {
|
None => break,
|
||||||
left = match left_iter.next() {
|
};
|
||||||
Some(x) => x,
|
}
|
||||||
None => break,
|
Ordering::Greater => {
|
||||||
};
|
right = match right_iter.next() {
|
||||||
continue;
|
Some(x) => x,
|
||||||
}
|
None => break,
|
||||||
|
};
|
||||||
if right.0 < left.0 {
|
}
|
||||||
right = match right_iter.next() {
|
|
||||||
Some(x) => x,
|
|
||||||
None => break,
|
|
||||||
};
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue