From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
"Shawn O. Pearce" <spearce@spearce.org>,
David Barr <davidbarr@google.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH 6/8] fast-import: cache oe in load_tree
Date: Mon, 19 Sep 2011 07:27:35 +0600 [thread overview]
Message-ID: <1316395657-6991-7-git-send-email-divanorama@gmail.com> (raw)
In-Reply-To: <1316395657-6991-1-git-send-email-divanorama@gmail.com>
load_tree reads a tree object given it's sha1. If there was no
struct object_entry allocated for this sha1, load_tree doesn't
allocate it and thus doesn't cache it's struct object_entry.
Make this read_sha1_file cached in struct object_entry.
Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
fast-import.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index dd3dcd5..1c0716b 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -599,6 +599,17 @@ static void resolve_sha1_object(struct object_entry *oe)
oe->idx.offset = 1; /* nonzero */
}
+static void *resolve_sha1_object_read(struct object_entry *oe, enum object_type *type, unsigned long *size)
+{
+ void *ret = read_sha1_file(oe->idx.sha1, type, size);
+ if (!ret)
+ return ret;
+ oe->type = *type;
+ oe->pack_id = MAX_PACK_ID;
+ oe->idx.offset = 1; /* nonzero */
+ return ret;
+}
+
static int try_resolve_sha1_pack_object(struct object_entry *e,
enum object_type type)
{
@@ -1363,8 +1374,8 @@ static void load_tree(struct tree_entry *root)
if (is_null_sha1(sha1))
return;
- myoe = find_object(sha1);
- if (myoe && myoe->pack_id != MAX_PACK_ID) {
+ myoe = insert_object(sha1);
+ if (myoe->idx.offset && myoe->pack_id != MAX_PACK_ID) {
if (myoe->type != OBJ_TREE)
die("Not a tree: %s", sha1_to_hex(sha1));
t->delta_depth = myoe->depth;
@@ -1373,7 +1384,10 @@ static void load_tree(struct tree_entry *root)
die("Can't load tree %s", sha1_to_hex(sha1));
} else {
enum object_type type;
- buf = read_sha1_file(sha1, &type, &size);
+ if (!myoe->idx.offset)
+ buf = resolve_sha1_object_read(myoe, &type, &size);
+ else
+ buf = read_sha1_file(sha1, &type, &size);
if (!buf || type != OBJ_TREE)
die("Can't load tree %s", sha1_to_hex(sha1));
}
--
1.7.3.4
next prev parent reply other threads:[~2011-09-19 1:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 1:27 [PATCH 0/8] fast-import: cache oe more often Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 1/8] fast-import: cache oe in file_change_m Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 2/8] fast-import: cache oe in parse_new_tag Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 3/8] fast-import: cache oe in note_change_n Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 4/8] fast-import: extract common sha1_file access functions Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 5/8] fast-import: tiny optimization in read_marks Dmitry Ivankov
2011-09-19 1:27 ` Dmitry Ivankov [this message]
2011-09-19 1:27 ` [PATCH 7/8] fast-import: cache oe in cat_blob Dmitry Ivankov
2011-09-19 1:27 ` [PATCH 8/8] fast-import: cache objects while dereferencing Dmitry Ivankov
2011-09-20 4:02 ` [PATCH 0/8] fast-import: cache oe more often Junio C Hamano
2011-09-20 4:26 ` Jonathan Nieder
2011-09-20 7:17 ` Dmitry Ivankov
2011-09-20 14:39 ` Jonathan Nieder
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=1316395657-6991-7-git-send-email-divanorama@gmail.com \
--to=divanorama@gmail.com \
--cc=davidbarr@google.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=spearce@spearce.org \
--cc=srabbelier@gmail.com \
/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).