Skip to content

Commit 4f823fb

Browse files
committed
Use saturating arithmetic on calculating row saving
The saturating arithmetic doesn't overflow, but stays at the maximum or minimum. In this case it doesn't become negative, but zero, which satisfies the condition below. Closes #31
1 parent b33c498 commit 4f823fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn main() {
229229
);
230230

231231
if let Some(min) = min_saved_rows {
232-
let saving = (original_summed_size - compressed_summed_size) as i32;
232+
let saving = original_summed_size.saturating_sub(compressed_summed_size);
233233
if saving < min {
234234
println!(
235235
"Only {} rows would be saved by this compression. Skipping output.",

0 commit comments

Comments
 (0)