Skip to content

Commit 3cd5896

Browse files
committed
Simplify compare_asset_fallback
1 parent 3a3e9a9 commit 3cd5896

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/simulation/investment/appraisal.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,10 @@ impl AppraisalOutput {
7171
}
7272
}
7373

74+
/// Sort commissioned assets first and newer before older
7475
fn compare_asset_fallback(asset1: &Asset, asset2: &Asset) -> Ordering {
75-
// Favour commissioned assets over non-commissioned
76-
if asset1.is_commissioned() && !asset2.is_commissioned() {
77-
return Ordering::Less;
78-
}
79-
if !asset1.is_commissioned() && asset2.is_commissioned() {
80-
return Ordering::Greater;
81-
}
82-
83-
// if both commissioned, favour newer ones
84-
if asset1.is_commissioned() && asset2.is_commissioned() {
85-
return asset1
86-
.commission_year()
87-
.cmp(&asset2.commission_year())
88-
.reverse();
89-
}
90-
91-
Ordering::Equal
76+
(asset2.is_commissioned(), asset2.commission_year())
77+
.cmp(&(asset1.is_commissioned(), asset1.commission_year()))
9278
}
9379

9480
/// Calculate LCOX for a hypothetical investment in the given asset.

0 commit comments

Comments
 (0)