path: root/builtin/diff-tree.c
diff options
authorJeff King <>2014-07-13 06:42:17 (GMT)
committerJunio C Hamano <>2014-07-14 01:59:05 (GMT)
commitfa96082617e07d988103854fb96c5e92b7587e72 (patch)
treee2b057838243a0e759fff2b2b7006ee618c81efb /builtin/diff-tree.c
parentd66bebcbcfa46d72bb5008e1d211c0ea87200d86 (diff)
diff-tree: avoid lookup_unknown_object
We generally want to avoid lookup_unknown_object, because it results in allocating more memory for the object than may be strictly necessary. In this case, it is used to check whether we have an already-parsed object before calling parse_object, to save us from reading the object from disk. Using lookup_object would be fine for that purpose, but we can take it a step further. Since this code was written, parse_object already learned the "check lookup_object" optimization, so we can simply call parse_object directly. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/diff-tree.c')
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index be6417d..dddd0f9 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -72,9 +72,7 @@ static int diff_tree_stdin(char *line)
line[len-1] = 0;
if (get_sha1_hex(line, sha1))
return -1;
- obj = lookup_unknown_object(sha1);
- if (!obj || !obj->parsed)
- obj = parse_object(sha1);
+ obj = parse_object(sha1);
if (!obj)
return -1;
if (obj->type == OBJ_COMMIT)