Initialize tree descriptors with a helper function rather than by hand.
This removes slightly more lines than it adds, but the real reason for doing this is that future optimizations will require more setup of the tree descriptor, and so we want to do it in one place. Also renamed the "desc.buf" field to "desc.buffer" just to trigger compiler errors for old-style manual initializations, making sure I didn't miss anything. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
a8c40471ab
commit
6fda5e5180
12
revision.c
12
revision.c
@ -62,8 +62,7 @@ void mark_tree_uninteresting(struct tree *tree)
|
||||
if (parse_tree(tree) < 0)
|
||||
die("bad tree %s", sha1_to_hex(obj->sha1));
|
||||
|
||||
desc.buf = tree->buffer;
|
||||
desc.size = tree->size;
|
||||
init_tree_desc(&desc, tree->buffer, tree->size);
|
||||
while (tree_entry(&desc, &entry)) {
|
||||
if (S_ISDIR(entry.mode))
|
||||
mark_tree_uninteresting(lookup_tree(entry.sha1));
|
||||
@ -275,18 +274,17 @@ int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
|
||||
{
|
||||
int retval;
|
||||
void *tree;
|
||||
unsigned long size;
|
||||
struct tree_desc empty, real;
|
||||
|
||||
if (!t1)
|
||||
return 0;
|
||||
|
||||
tree = read_object_with_reference(t1->object.sha1, tree_type, &real.size, NULL);
|
||||
tree = read_object_with_reference(t1->object.sha1, tree_type, &size, NULL);
|
||||
if (!tree)
|
||||
return 0;
|
||||
real.buf = tree;
|
||||
|
||||
empty.buf = "";
|
||||
empty.size = 0;
|
||||
init_tree_desc(&real, tree, size);
|
||||
init_tree_desc(&empty, "", 0);
|
||||
|
||||
tree_difference = REV_TREE_SAME;
|
||||
revs->pruning.has_changes = 0;
|
||||
|
||||
Reference in New Issue
Block a user