From: Elijah Newren <newren@xxxxxxxxx> diffcore-rename had two different checks of the form if ((a < limit || b < limit) && a * b <= limit * limit) Since these are all non-negative integers, this can be simplified to if (a * b <= limit * limit) The only advantage of the former would be in avoiding a couple multiplications in the rare case that both a and b are BOTH very large. I see no reason for such an optimization given that this code is not in any kind of loop. Prefer code simplicity here and change to the latter form. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- diffcore-rename.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/diffcore-rename.c b/diffcore-rename.c index 68ddf51a2a1..0f8fce9293e 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -450,9 +450,8 @@ static int too_many_rename_candidates(int num_targets, int num_sources, */ if (rename_limit <= 0) rename_limit = 32767; - if ((num_targets <= rename_limit || num_sources <= rename_limit) && - ((uint64_t)num_targets * (uint64_t)num_sources - <= (uint64_t)rename_limit * (uint64_t)rename_limit)) + if ((uint64_t)num_targets * (uint64_t)num_sources + <= (uint64_t)rename_limit * (uint64_t)rename_limit) return 0; options->needed_rename_limit = @@ -468,9 +467,8 @@ static int too_many_rename_candidates(int num_targets, int num_sources, continue; limited_sources++; } - if ((num_targets <= rename_limit || limited_sources <= rename_limit) && - ((uint64_t)num_targets * (uint64_t)limited_sources - <= (uint64_t)rename_limit * (uint64_t)rename_limit)) + if ((uint64_t)num_targets * (uint64_t)limited_sources + <= (uint64_t)rename_limit * (uint64_t)rename_limit) return 2; return 1; } -- gitgitgadget