Skip to content

Commit e25ea79

Browse files
committed
memory: use saturating_sub
1 parent 1b31489 commit e25ea79

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/blocks/memory.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ pub async fn run(config: Config, mut api: CommonApi) -> Result<()> {
119119
// While zfs_arc_cache can be considered "available" memory,
120120
// it can only free a maximum of (zfs_arc_cache - zfs_arc_min) amount.
121121
// see https://github.com/htop-dev/htop/pull/1003
122-
let zfs_shrinkable_size = if mem_state.zfs_arc_cache > mem_state.zfs_arc_min {
123-
mem_state.zfs_arc_cache - mem_state.zfs_arc_min
124-
} else {
125-
0
126-
} as f64;
122+
let zfs_shrinkable_size = mem_state
123+
.zfs_arc_cache
124+
.saturating_sub(mem_state.zfs_arc_min) as f64;
127125
let mem_avail = mem_avail + zfs_shrinkable_size;
128126

129127
let pagecache = mem_state.pagecache as f64 * 1024.;

0 commit comments

Comments
 (0)