From 0e104647a7bf727f273228c2a3292699c8f17f67 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 27 Jun 2025 17:52:15 -0700 Subject: [PATCH] od: minor lcm tuning * src/od.c (dump, main): Redo lcm calcuations to avoid a multiply. --- src/od.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/od.c b/src/od.c index df89c69c77..fd2e2138ec 100644 --- a/src/od.c +++ b/src/od.c @@ -1527,7 +1527,8 @@ dump (void) /* Ensure zero-byte padding up to the smallest multiple of l_c_m that is at least as large as n_bytes_read. */ - idx_t bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m); + idx_t bytes_to_write = (n_bytes_read + l_c_m - 1 + - (n_bytes_read + l_c_m - 1) % l_c_m); memset (block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read); write_block (current_offset, n_bytes_read, block[!idx], block[idx]); @@ -1997,7 +1998,8 @@ main (int argc, char **argv) else { if (l_c_m < DEFAULT_BYTES_PER_BLOCK) - bytes_per_block = l_c_m * (DEFAULT_BYTES_PER_BLOCK / l_c_m); + bytes_per_block = (DEFAULT_BYTES_PER_BLOCK + - DEFAULT_BYTES_PER_BLOCK % l_c_m); else bytes_per_block = l_c_m; } -- 2.47.3