git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH 1/3] Simplify index access condition in count-objects, pack-redundant
Date: Wed, 30 May 2007 02:12:28 -0400	[thread overview]
Message-ID: <20070530061228.GA12738@spearce.org> (raw)

My earlier lazy index opening patch changed this condition to check
index_data and call open_pack_index if it was NULL. In truth we only
care about num_objects.  Since open_pack_index does no harm if the
index is already open, and all indexes are likely to be closed in
this application, the "performance optimization" of inlining the
index_data check here was wrong.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---

 First of a 3 part series to cleanup behind the lazy index patch.
 This particular one was stupid; the lazy index patch never should
 have been submitted with the conditions like this.

 After this series, I'm pretty sure we've got everything covered.
 Additional eyes from other people wouldn't hurt, but I have gone
 through every caller several times now and am pretty sure they
 are all correct.

 Note that we are *not* safe to unload an index once opened; unlike
 the use_pack() interface the index_data interface does not offer a
 way for a caller to pin the index_data into memory for the duration
 of the block.  That's one reason I haven't tried to GC indexes yet.

 builtin-count-objects.c |    2 +-
 pack-redundant.c        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index ac65e03..4274ec1 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -111,7 +111,7 @@ int cmd_count_objects(int ac, const char **av, const char *prefix)
 		for (p = packed_git; p; p = p->next) {
 			if (!p->pack_local)
 				continue;
-			if (!p->index_data && open_pack_index(p))
+			if (open_pack_index(p))
 				continue;
 			packed += p->num_objects;
 			num_pack++;
diff --git a/pack-redundant.c b/pack-redundant.c
index 0617320..6bc3bdf 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -550,7 +550,7 @@ static struct pack_list * add_pack(struct packed_git *p)
 	l.pack = p;
 	llist_init(&l.all_objects);
 
-	if (!p->index_data && open_pack_index(p))
+	if (open_pack_index(p))
 		return NULL;
 
 	base = p->index_data;
-- 
1.5.2.869.g6b3ba

                 reply	other threads:[~2007-05-30  6:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20070530061228.GA12738@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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.
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 NNTP newsgroup(s).