Skip to content

Commit b794ebe

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34dfe19 commit b794ebe

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

builtin/diff-tree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ static int diff_tree_stdin(char *line)
7272
line[len-1] = 0;
7373
if (get_sha1_hex(line, sha1))
7474
return -1;
75-
obj = lookup_unknown_object(sha1);
76-
if (!obj || !obj->parsed)
77-
obj = parse_object(sha1);
75+
obj = parse_object(sha1);
7876
if (!obj)
7977
return -1;
8078
if (obj->type == OBJ_COMMIT)

0 commit comments

Comments
 (0)