git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net
Subject: [PATCH 3/5] builtin/repack.c: assign pack split later
Date: Fri, 5 Mar 2021 10:21:50 -0500	[thread overview]
Message-ID: <60f13524bd602517c41554898b213161e9d603ce.1614957681.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1614957681.git.me@ttaylorr.com>

To determine the where to place the split when repacking with the
'--geometric' option, split_pack_geometry() assigns the "split" variable
and then decrements it in a loop.

It would be equivalent (and more readable) to assign the split to the
loop position after exiting the loop, so do that instead.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/repack.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/builtin/repack.c b/builtin/repack.c
index 4ca2f647b4..21a5778e73 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -356,8 +356,6 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
 		return;
 	}
 
-	split = geometry->pack_nr - 1;
-
 	/*
 	 * First, count the number of packs (in descending order of size) which
 	 * already form a geometric progression.
@@ -365,12 +363,12 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
 	for (i = geometry->pack_nr - 1; i > 0; i--) {
 		struct packed_git *ours = geometry->pack[i];
 		struct packed_git *prev = geometry->pack[i - 1];
-		if (geometry_pack_weight(ours) >= factor * geometry_pack_weight(prev))
-			split--;
-		else
+		if (geometry_pack_weight(ours) < factor * geometry_pack_weight(prev))
 			break;
 	}
 
+	split = i;
+
 	if (split) {
 		/*
 		 * Move the split one to the right, since the top element in the
-- 
2.30.0.667.g81c0cbc6fd


  parent reply	other threads:[~2021-03-05 15:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 15:21 [PATCH 0/5] clean-ups to geometric repacking Taylor Blau
2021-03-05 15:21 ` [PATCH 1/5] builtin/repack.c: do not repack single packs with --geometric Taylor Blau
2021-03-05 19:15   ` Junio C Hamano
2021-03-05 19:27     ` Taylor Blau
2021-03-05 19:30       ` Taylor Blau
2021-03-05 15:21 ` [PATCH 2/5] t7703: test --geometric repack with loose objects Taylor Blau
2021-03-05 15:21 ` Taylor Blau [this message]
2021-03-05 15:21 ` [PATCH 4/5] builtin/repack.c: be more conservative with unsigned overflows Taylor Blau
2021-03-05 19:32   ` Junio C Hamano
2021-03-05 19:41     ` Taylor Blau
2021-03-10 21:00   ` Jeff King
2021-03-05 15:22 ` [PATCH 5/5] builtin/repack.c: reword comment around pack-objects flags Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60f13524bd602517c41554898b213161e9d603ce.1614957681.git.me@ttaylorr.com \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).