From: Paul Eggert Date: Sat, 28 Jun 2025 00:52:15 +0000 (-0700) Subject: od: minor lcm tuning X-Git-Tag: v9.8~271 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e104647a7bf727f273228c2a3292699c8f17f67;p=thirdparty%2Fcoreutils.git od: minor lcm tuning * src/od.c (dump, main): Redo lcm calcuations to avoid a multiply. --- 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; }