mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
lru: using max to simplify the if statement
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
This commit is contained in:
parent
36e09ca389
commit
6d2613d254
1 changed files with 1 additions and 1 deletions
|
@ -68,7 +68,7 @@ impl<T, const N: usize> Lru<T, N> {
|
||||||
|
|
||||||
// Make sure weight is positive otherwise eviction won't work
|
// Make sure weight is positive otherwise eviction won't work
|
||||||
// TODO: Probably should use NonZeroUsize instead
|
// 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);
|
let old_weight = unit.admit(key, data, weight);
|
||||||
if old_weight != weight {
|
if old_weight != weight {
|
||||||
|
|
Loading…
Reference in a new issue