lru: using max to simplify the if statement

Includes-commit: 6d2613d254
Replicated-from: https://github.com/cloudflare/pingora/pull/130
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
This commit is contained in:
Xiaobo Liu 2024-03-11 03:29:59 +00:00 committed by Yuchen Wu
parent 3675d35f1c
commit 99cb79bf2b
2 changed files with 2 additions and 2 deletions

2
.bleep
View file

@ -1 +1 @@
d2b0975beaec744968a4936eb80483fac65f7e35
802590d7d04730c3e93f9c2335175990eee1fb92

View file

@ -68,7 +68,7 @@ impl<T, const N: usize> Lru<T, N> {
// Make sure weight is positive otherwise eviction won't work
// TODO: Probably should use NonZeroUsize instead
let weight = if weight == 0 { 1 } else { weight };
let weight = weight.max(1);
let old_weight = unit.admit(key, data, weight);
if old_weight != weight {