[PATCH] fetch.c: Remove useless lookup_object_type() call in process()
In all places where process() is called except the one in pull() (which is executed only once) the pointer to the object is already available, so pass it as the argument to process() instead of sha1 and avoid an unneeded call to lookup_object_type(). Signed-off-by: Sergey Vlasov <vsu@altlinux.ru> Signed-off-by: Junio C Hamano <junkio@cox.net>
Sergey Vlasov committed
Sep 21, 2005 at 20:33 UTC
e8d2a6d483a6f556a509fc8debdb9391a5fa2630
1 file changed
+10
-13
fetch.c
+10
-13
@@ -33,7 +33,7 @@ static void report_missing(const char *what, const unsigned char *missing)
33
what, missing_hex, sha1_to_hex(current_commit_sha1));
34
}
35
36
-static int process(unsigned char *sha1, const char *type);
36
+static int process(struct object *obj);
37
38
static int process_tree(struct tree *tree)
39
{
@@ -46,8 +46,7 @@ static int process_tree(struct tree *tree)
46
tree->entries = NULL;
47
while (entry) {
48
struct tree_entry_list *next = entry->next;
49
- if (process(entry->item.any->sha1,
50
- entry->directory ? tree_type : blob_type))
49
+ if (process(entry->item.any))
50
return -1;
51
free(entry);
52
entry = next;
@@ -79,7 +78,7 @@ static int process_commit(struct commit *commit)
78
pull_say("walk %s\n", sha1_to_hex(commit->object.sha1));
79
80
if (get_tree) {
82
- if (process(commit->tree->object.sha1, tree_type))
81
+ if (process(&commit->tree->object))
82
return -1;
83
if (!get_all)
84
get_tree = 0;
@@ -87,7 +86,7 @@ static int process_commit(struct commit *commit)
86
if (get_history) {
87
struct commit_list *parents = commit->parents;
88
for (; parents; parents = parents->next) {
90
- if (process(parents->item->object.sha1, commit_type))
89
+ if (process(&parents->item->object))
90
return -1;
91
}
92
}
@@ -98,7 +97,7 @@ static int process_tag(struct tag *tag)
97
{
98
if (parse_tag(tag))
99
return -1;
101
- return process(tag->tagged->sha1, NULL);
100
+ return process(tag->tagged);
101
}
102
103
static struct object_list *process_queue = NULL;
@@ -133,12 +132,10 @@ static int process_object(struct object *obj)
132
obj->type, sha1_to_hex(obj->sha1));
133
}
134
136
-static int process(unsigned char *sha1, const char *type)
135
+static int process(struct object *obj)
136
{
138
- struct object *obj = lookup_object_type(sha1, type);
139
-
140
- if (has_sha1_file(sha1)) {
141
- parse_object(sha1);
137
+ if (has_sha1_file(obj->sha1)) {
138
+ parse_object(obj->sha1);
139
/* We already have it, so we should scan it now. */
140
if (obj->flags & (SCANNED | TO_SCAN))
141
return 0;
@@ -153,7 +150,7 @@ static int process(unsigned char *sha1, const char *type)
150
process_queue_end = &(*process_queue_end)->next;
151
obj->flags |= TO_FETCH;
152
156
- prefetch(sha1);
153
+ prefetch(obj->sha1);
154
155
return 0;
156
}
@@ -228,7 +225,7 @@ int pull(char *target)
225
if (interpret_target(target, sha1))
226
return error("Could not interpret %s as something to pull",
227
target);
231
- if (process(sha1, NULL))
228
+ if (process(lookup_unknown_object(sha1)))
229
return -1;
230
if (loop())
231
return -1;