Skip to content

Commit 1a732b9

Browse files
committed
f - use fewer operations
1 parent feaed9b commit 1a732b9

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lightning/src/routing/scoring.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1009,14 +1009,11 @@ impl<L: Deref<Target = u64>, BRT: Deref<Target = HistoricalBucketRangeTracker>,
10091009
// half life has passed, approximate an additional three-quarter life by summing
10101010
// the results of taking both the *next two* half lives instead. This helps
10111011
// smooth out the decay.
1012+
let decayed_offset_msat = offset_msat.checked_shr(decays as u32).unwrap_or(0);
10121013
if half_decays % 2 == 0 {
1013-
offset_msat.checked_shr(decays as u32).unwrap_or(0)
1014+
decayed_offset_msat
10141015
} else {
1015-
offset_msat
1016-
.checked_shr((decays + 1) as u32)
1017-
.map(|decayed_offset_msat| decayed_offset_msat
1018-
+ offset_msat.checked_shr((decays + 2) as u32).unwrap_or(0))
1019-
.unwrap_or(0)
1016+
(decayed_offset_msat >> 1) + (decayed_offset_msat >> 2)
10201017
}
10211018
}
10221019
},

0 commit comments

Comments
 (0)