From e8a7dab95c64b70cec2fcbccb2696305ea36da13 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 3 Jun 2023 15:24:54 -0700 Subject: [PATCH] diff: calculate log2 faster in io.c * src/io.c (find_identical_ends): Use floor_log2 instead of computing log base 2 by hand. --- src/io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/io.c b/src/io.c index 40132b0..f3b1cb1 100644 --- a/src/io.c +++ b/src/io.c @@ -667,8 +667,7 @@ find_identical_ends (struct file_data filevec[]) { middle_guess = guess_lines (0, 0, p0 - filevec[0].prefix_end); lin suffix_guess = guess_lines (0, 0, buffer0 + n0 - p0); - for (prefix_count = 1; prefix_count <= context; prefix_count *= 2) - continue; + prefix_count = (lin) 1 << (floor_log2 (context) + 1); alloc_lines0 = (prefix_count + middle_guess + MIN (context, suffix_guess)); }