@matheusbsbs / matheus-bagliano / commits / 1f1e895fcc
Fork 0

Add "named object array" concept

We've had this notion of a "object_list" for a long time, which eventually grew a "name" member because some users (notably git-rev-list) wanted to name each object as it is generated. That object_list is great for some things, but it isn't all that wonderful for others, and the "name" member is generally not used by everybody. This patch splits the users of the object_list array up into two: the traditional list users, who want the list-like format, and who don't actually use or want the name. And another class of users that really used the list as an extensible array, and generally wanted to name the objects. The patch is fairly straightforward, but it's also biggish. Most of it really just cleans things up: switching the revision parsing and listing over to the array makes things like the builtin-diff usage much simpler (we now see exactly how many members the array has, and we don't get the objects reversed from the order they were on the command line). One of the main reasons for doing this at all is that the malloc overhead of the simple object list was actually pretty high, and the array is just a lot denser. So this patch brings down memory usage by git-rev-list by just under 3% (on top of all the other memory use optimizations) on the mozilla archive. It does add more lines than it removes, and more importantly, it adds a whole new infrastructure for maintaining lists of objects, but on the other hand, the new dynamic array code is pretty obvious. The change to builtin-diff-tree.c shows a fairly good example of why an array interface is sometimes more natural, and just much simpler for everybody. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Jun 19, 2006 at 17:42 UTC 1f1e895fccc52a1e227c464c4558d74604301a9f
14 files changed +151 -131
builtin-diff-files.c
+1 -1
@@ -41,7 +41,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
41 * rev.max_count is reasonable (0 <= n <= 3),
42 * there is no other revision filtering parameters.
43 */
44 - if (rev.pending_objects ||
44 + if (rev.pending.nr ||
45 rev.min_age != -1 || rev.max_age != -1)
46 usage(diff_files_usage);
47 /*
builtin-diff-index.c
+1 -1
@@ -32,7 +32,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
32 * Make sure there is one revision (i.e. pending object),
33 * and there is no revision filtering parameters.
34 */
35 - if (!rev.pending_objects || rev.pending_objects->next ||
35 + if (rev.pending.nr != 1 ||
36 rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
37 usage(diff_cache_usage);
38 return run_diff_index(&rev, cached);
builtin-diff-tree.c
+12 -30
@@ -65,7 +65,6 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
65 char line[1000];
66 struct object *tree1, *tree2;
67 static struct rev_info *opt = &log_tree_opt;
68 - struct object_list *list;
68 int read_stdin = 0;
69
70 git_config(git_diff_config);
@@ -86,45 +85,28 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
85 }
86
87 /*
89 - * NOTE! "setup_revisions()" will have inserted the revisions
90 - * it parsed in reverse order. So if you do
91 - *
92 - * git-diff-tree a b
93 - *
94 - * the commit list will be "b" -> "a" -> NULL, so we reverse
95 - * the order of the objects if the first one is not marked
96 - * UNINTERESTING.
88 + * NOTE! We expect "a ^b" to be equal to "a..b", so we
89 + * reverse the order of the objects if the second one
90 + * is marked UNINTERESTING.
91 */
98 - nr_sha1 = 0;
99 - list = opt->pending_objects;
100 - if (list) {
101 - nr_sha1++;
102 - tree1 = list->item;
103 - list = list->next;
104 - if (list) {
105 - nr_sha1++;
106 - tree2 = tree1;
107 - tree1 = list->item;
108 - if (list->next)
109 - usage(diff_tree_usage);
110 - /* Switch them around if the second one was uninteresting.. */
111 - if (tree2->flags & UNINTERESTING) {
112 - struct object *tmp = tree2;
113 - tree2 = tree1;
114 - tree1 = tmp;
115 - }
116 - }
117 - }
118 -
92 + nr_sha1 = opt->pending.nr;
93 switch (nr_sha1) {
94 case 0:
95 if (!read_stdin)
96 usage(diff_tree_usage);
97 break;
98 case 1:
99 + tree1 = opt->pending.objects[0].item;
100 diff_tree_commit_sha1(tree1->sha1);
101 break;
102 case 2:
103 + tree1 = opt->pending.objects[0].item;
104 + tree2 = opt->pending.objects[1].item;
105 + if (tree2->flags & UNINTERESTING) {
106 + struct object *tmp = tree2;
107 + tree2 = tree1;
108 + tree1 = tmp;
109 + }
110 diff_tree_sha1(tree1->sha1,
111 tree2->sha1,
112 "", &opt->diffopt);
builtin-diff.c
+14 -12
@@ -50,7 +50,7 @@ static int builtin_diff_files(struct rev_info *revs,
50 * specified rev.max_count is reasonable (0 <= n <= 3), and
51 * there is no other revision filtering parameter.
52 */
53 - if (revs->pending_objects ||
53 + if (revs->pending.nr ||
54 revs->min_age != -1 ||
55 revs->max_age != -1 ||
56 3 < revs->max_count)
@@ -172,7 +172,7 @@ static int builtin_diff_index(struct rev_info *revs,
172 * Make sure there is one revision (i.e. pending object),
173 * and there is no revision filtering parameters.
174 */
175 - if (!revs->pending_objects || revs->pending_objects->next ||
175 + if (revs->pending.nr != 1 ||
176 revs->max_count != -1 || revs->min_age != -1 ||
177 revs->max_age != -1)
178 usage(builtin_diff_usage);
@@ -181,10 +181,10 @@ static int builtin_diff_index(struct rev_info *revs,
181
182 static int builtin_diff_tree(struct rev_info *revs,
183 int argc, const char **argv,
184 - struct object_list *ent)
184 + struct object_array_entry *ent)
185 {
186 const unsigned char *(sha1[2]);
187 - int swap = 1;
187 + int swap = 0;
188 while (1 < argc) {
189 const char *arg = argv[1];
190 if (!strcmp(arg, "--raw"))
@@ -195,10 +195,10 @@ static int builtin_diff_tree(struct rev_info *revs,
195 }
196
197 /* We saw two trees, ent[0] and ent[1].
198 - * unless ent[0] is unintesting, they are swapped
198 + * if ent[1] is unintesting, they are swapped
199 */
200 - if (ent[0].item->flags & UNINTERESTING)
201 - swap = 0;
200 + if (ent[1].item->flags & UNINTERESTING)
201 + swap = 1;
202 sha1[swap] = ent[0].item->sha1;
203 sha1[1-swap] = ent[1].item->sha1;
204 diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
@@ -208,7 +208,7 @@ static int builtin_diff_tree(struct rev_info *revs,
208
209 static int builtin_diff_combined(struct rev_info *revs,
210 int argc, const char **argv,
211 - struct object_list *ent,
211 + struct object_array_entry *ent,
212 int ents)
213 {
214 const unsigned char (*parent)[20];
@@ -242,13 +242,14 @@ void add_head(struct rev_info *revs)
242 obj = parse_object(sha1);
243 if (!obj)
244 return;
245 - add_object(obj, &revs->pending_objects, NULL, "HEAD");
245 + add_pending_object(revs, obj, "HEAD");
246 }
247
248 int cmd_diff(int argc, const char **argv, char **envp)
249 {
250 + int i;
251 struct rev_info rev;
251 - struct object_list *list, ent[100];
252 + struct object_array_entry ent[100];
253 int ents = 0, blobs = 0, paths = 0;
254 const char *path = NULL;
255 struct blobinfo blob[2];
@@ -281,7 +282,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
282 /* Do we have --cached and not have a pending object, then
283 * default to HEAD by hand. Eek.
284 */
284 - if (!rev.pending_objects) {
285 + if (!rev.pending.nr) {
286 int i;
287 for (i = 1; i < argc; i++) {
288 const char *arg = argv[i];
@@ -294,7 +295,8 @@ int cmd_diff(int argc, const char **argv, char **envp)
295 }
296 }
297
297 - for (list = rev.pending_objects; list; list = list->next) {
298 + for (i = 0; i < rev.pending.nr; i++) {
299 + struct object_array_entry *list = rev.pending.objects+i;
300 struct object *obj = list->item;
301 const char *name = list->name;
302 int flags = (obj->flags & UNINTERESTING);
builtin-grep.c
+6 -10
@@ -657,7 +657,7 @@ int cmd_grep(int argc, const char **argv, char **envp)
657 int cached = 0;
658 int seen_dashdash = 0;
659 struct grep_opt opt;
660 - struct object_list *list, **tail, *object_list = NULL;
660 + struct object_array list = { 0, 0, NULL };
661 const char *prefix = setup_git_directory();
662 const char **paths = NULL;
663 int i;
@@ -677,7 +677,6 @@ int cmd_grep(int argc, const char **argv, char **envp)
677 * that continues up to the -- (if exists), and then paths.
678 */
679
680 - tail = &object_list;
680 while (1 < argc) {
681 const char *arg = argv[1];
682 argc--; argv++;
@@ -851,12 +850,9 @@ int cmd_grep(int argc, const char **argv, char **envp)
850 /* Is it a rev? */
851 if (!get_sha1(arg, sha1)) {
852 struct object *object = parse_object(sha1);
854 - struct object_list *elem;
853 if (!object)
854 die("bad object %s", arg);
857 - elem = object_list_insert(object, tail);
858 - elem->name = arg;
859 - tail = &elem->next;
855 + add_object_array(object, arg, &list);
856 continue;
857 }
858 if (!strcmp(arg, "--")) {
@@ -881,16 +877,16 @@ int cmd_grep(int argc, const char **argv, char **envp)
877 paths[1] = NULL;
878 }
879
884 - if (!object_list)
880 + if (!list.nr)
881 return !grep_cache(&opt, paths, cached);
882
883 if (cached)
884 die("both --cached and trees are given.");
885
890 - for (list = object_list; list; list = list->next) {
886 + for (i = 0; i < list.nr; i++) {
887 struct object *real_obj;
892 - real_obj = deref_tag(list->item, NULL, 0);
893 - if (grep_object(&opt, paths, real_obj, list->name))
888 + real_obj = deref_tag(list.objects[i].item, NULL, 0);
889 + if (grep_object(&opt, paths, real_obj, list.objects[i].name))
890 hit = 1;
891 }
892 return !hit;
builtin-log.c
+2 -2
@@ -257,8 +257,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
257 output_directory);
258 }
259
260 - if (rev.pending_objects && rev.pending_objects->next == NULL) {
261 - rev.pending_objects->item->flags |= UNINTERESTING;
260 + if (rev.pending.nr == 1) {
261 + rev.pending.objects[0].item->flags |= UNINTERESTING;
262 add_head(&rev);
263 }
264
builtin-rev-list.c
+33 -31
@@ -99,26 +99,26 @@ static void show_commit(struct commit *commit)
99 }
100 }
101
102 -static struct object_list **process_blob(struct blob *blob,
103 - struct object_list **p,
104 - struct name_path *path,
105 - const char *name)
102 +static void process_blob(struct blob *blob,
103 + struct object_array *p,
104 + struct name_path *path,
105 + const char *name)
106 {
107 struct object *obj = &blob->object;
108
109 if (!revs.blob_objects)
110 - return p;
110 + return;
111 if (obj->flags & (UNINTERESTING | SEEN))
112 - return p;
112 + return;
113 obj->flags |= SEEN;
114 name = strdup(name);
115 - return add_object(obj, p, path, name);
115 + add_object(obj, p, path, name);
116 }
117
118 -static struct object_list **process_tree(struct tree *tree,
119 - struct object_list **p,
120 - struct name_path *path,
121 - const char *name)
118 +static void process_tree(struct tree *tree,
119 + struct object_array *p,
120 + struct name_path *path,
121 + const char *name)
122 {
123 struct object *obj = &tree->object;
124 struct tree_desc desc;
@@ -126,14 +126,14 @@ static struct object_list **process_tree(struct tree *tree,
126 struct name_path me;
127
128 if (!revs.tree_objects)
129 - return p;
129 + return;
130 if (obj->flags & (UNINTERESTING | SEEN))
131 - return p;
131 + return;
132 if (parse_tree(tree) < 0)
133 die("bad tree object %s", sha1_to_hex(obj->sha1));
134 obj->flags |= SEEN;
135 name = strdup(name);
136 - p = add_object(obj, p, path, name);
136 + add_object(obj, p, path, name);
137 me.up = path;
138 me.elem = name;
139 me.elem_len = strlen(name);
@@ -143,57 +143,59 @@ static struct object_list **process_tree(struct tree *tree,
143
144 while (tree_entry(&desc, &entry)) {
145 if (S_ISDIR(entry.mode))
146 - p = process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
146 + process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
147 else
148 - p = process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
148 + process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
149 }
150 free(tree->buffer);
151 tree->buffer = NULL;
152 - return p;
152 }
153
154 static void show_commit_list(struct rev_info *revs)
155 {
156 + int i;
157 struct commit *commit;
158 - struct object_list *objects = NULL, **p = &objects, *pending;
158 + struct object_array objects = { 0, 0, NULL };
159
160 while ((commit = get_revision(revs)) != NULL) {
161 - p = process_tree(commit->tree, p, NULL, "");
161 + process_tree(commit->tree, &objects, NULL, "");
162 show_commit(commit);
163 }
164 - for (pending = revs->pending_objects; pending; pending = pending->next) {
164 + for (i = 0; i < revs->pending.nr; i++) {
165 + struct object_array_entry *pending = revs->pending.objects + i;
166 struct object *obj = pending->item;
167 const char *name = pending->name;
168 if (obj->flags & (UNINTERESTING | SEEN))
169 continue;
170 if (obj->type == TYPE_TAG) {
171 obj->flags |= SEEN;
171 - p = add_object(obj, p, NULL, name);
172 + add_object_array(obj, name, &objects);
173 continue;
174 }
175 if (obj->type == TYPE_TREE) {
175 - p = process_tree((struct tree *)obj, p, NULL, name);
176 + process_tree((struct tree *)obj, &objects, NULL, name);
177 continue;
178 }
179 if (obj->type == TYPE_BLOB) {
179 - p = process_blob((struct blob *)obj, p, NULL, name);
180 + process_blob((struct blob *)obj, &objects, NULL, name);
181 continue;
182 }
183 die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
184 }
184 - while (objects) {
185 + for (i = 0; i < objects.nr; i++) {
186 + struct object_array_entry *p = objects.objects + i;
187 +
188 /* An object with name "foo\n0000000..." can be used to
189 * confuse downstream git-pack-objects very badly.
190 */
188 - const char *ep = strchr(objects->name, '\n');
191 + const char *ep = strchr(p->name, '\n');
192 if (ep) {
190 - printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
191 - (int) (ep - objects->name),
192 - objects->name);
193 + printf("%s %.*s\n", sha1_to_hex(p->item->sha1),
194 + (int) (ep - p->name),
195 + p->name);
196 }
197 else
195 - printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
196 - objects = objects->next;
198 + printf("%s %s\n", sha1_to_hex(p->item->sha1), p->name);
199 }
200 }
201
@@ -348,7 +350,7 @@ int cmd_rev_list(int argc, const char **argv, char **envp)
350
351 if ((!list &&
352 (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
351 - !revs.pending_objects)) ||
353 + !revs.pending.nr)) ||
354 revs.diff)
355 usage(rev_list_usage);
356
diff-lib.c
+2 -2
@@ -329,8 +329,8 @@ int run_diff_index(struct rev_info *revs, int cached)
329 }
330 mark_merge_entries();
331
332 - ent = revs->pending_objects->item;
333 - tree_name = revs->pending_objects->name;
332 + ent = revs->pending.objects[0].item;
333 + tree_name = revs->pending.objects[0].name;
334 tree = parse_tree_indirect(ent->sha1);
335 if (!tree)
336 return error("bad tree object %s", tree_name);
http-push.c
+19 -9
@@ -1171,7 +1171,7 @@ static void one_remote_object(const char *hex)
1171
1172 obj->flags |= REMOTE;
1173 if (!object_list_contains(objects, obj))
1174 - add_object(obj, &objects, NULL, "");
1174 + object_list_insert(obj, &objects);
1175 }
1176
1177 static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
@@ -1699,6 +1699,15 @@ static int locking_available(void)
1699 return lock_flags;
1700 }
1701
1702 +struct object_list **add_one_object(struct object *obj, struct object_list **p)
1703 +{
1704 + struct object_list *entry = xmalloc(sizeof(struct object_list));
1705 + entry->item = obj;
1706 + entry->next = *p;
1707 + *p = entry;
1708 + return &entry->next;
1709 +}
1710 +
1711 static struct object_list **process_blob(struct blob *blob,
1712 struct object_list **p,
1713 struct name_path *path,
@@ -1712,8 +1721,7 @@ static struct object_list **process_blob(struct blob *blob,
1721 return p;
1722
1723 obj->flags |= SEEN;
1715 - name = strdup(name);
1716 - return add_object(obj, p, path, name);
1724 + return add_one_object(obj, p);
1725 }
1726
1727 static struct object_list **process_tree(struct tree *tree,
@@ -1735,7 +1743,7 @@ static struct object_list **process_tree(struct tree *tree,
1743
1744 obj->flags |= SEEN;
1745 name = strdup(name);
1738 - p = add_object(obj, p, NULL, name);
1746 + p = add_one_object(obj, p);
1747 me.up = path;
1748 me.elem = name;
1749 me.elem_len = strlen(name);
@@ -1756,8 +1764,9 @@ static struct object_list **process_tree(struct tree *tree,
1764
1765 static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1766 {
1767 + int i;
1768 struct commit *commit;
1760 - struct object_list **p = &objects, *pending;
1769 + struct object_list **p = &objects;
1770 int count = 0;
1771
1772 while ((commit = get_revision(revs)) != NULL) {
@@ -1767,15 +1776,16 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
1776 count += add_send_request(&commit->object, lock);
1777 }
1778
1770 - for (pending = revs->pending_objects; pending; pending = pending->next) {
1771 - struct object *obj = pending->item;
1772 - const char *name = pending->name;
1779 + for (i = 0; i < revs->pending.nr; i++) {
1780 + struct object_array_entry *entry = revs->pending.objects + i;
1781 + struct object *obj = entry->item;
1782 + const char *name = entry->name;
1783
1784 if (obj->flags & (UNINTERESTING | SEEN))
1785 continue;
1786 if (obj->type == TYPE_TAG) {
1787 obj->flags |= SEEN;
1778 - p = add_object(obj, p, NULL, name);
1788 + p = add_one_object(obj, p);
1789 continue;
1790 }
1791 if (obj->type == TYPE_TREE) {
name-rev.c
+10 -9
@@ -125,11 +125,10 @@ static const char* get_rev_name(struct object *o)
125
126 return buffer;
127 }
128 -
128 +
129 int main(int argc, char **argv)
130 {
131 - struct object_list *revs = NULL;
132 - struct object_list **walker = &revs;
131 + struct object_array revs = { 0, 0, NULL };
132 int as_is = 0, all = 0, transform_stdin = 0;
133
134 setup_git_directory();
@@ -184,9 +183,7 @@ int main(int argc, char **argv)
183 if (cutoff > commit->date)
184 cutoff = commit->date;
185
187 - object_list_append((struct object *)commit, walker);
188 - (*walker)->name = *argv;
189 - walker = &((*walker)->next);
186 + add_object_array((struct object *)commit, *argv, &revs);
187 }
188
189 for_each_ref(name_ref);
@@ -243,9 +240,13 @@ int main(int argc, char **argv)
240 if (objs[i])
241 printf("%s %s\n", sha1_to_hex(objs[i]->sha1),
242 get_rev_name(objs[i]));
246 - } else
247 - for ( ; revs; revs = revs->next)
248 - printf("%s %s\n", revs->name, get_rev_name(revs->item));
243 + } else {
244 + int i;
245 + for (i = 0; i < revs.nr; i++)
246 + printf("%s %s\n",
247 + revs.objects[i].name,
248 + get_rev_name(revs.objects[i].item));
249 + }
250
251 return 0;
252 }
object.c
+17
@@ -200,3 +200,20 @@ int object_list_contains(struct object_list *list, struct object *obj)
200 }
201 return 0;
202 }
203 +
204 +void add_object_array(struct object *obj, const char *name, struct object_array *array)
205 +{
206 + unsigned nr = array->nr;
207 + unsigned alloc = array->alloc;
208 + struct object_array_entry *objects = array->objects;
209 +
210 + if (nr >= alloc) {
211 + alloc = (alloc + 32) * 2;
212 + objects = xrealloc(objects, alloc * sizeof(*objects));
213 + array->alloc = alloc;
214 + array->objects = objects;
215 + }
216 + objects[nr].item = obj;
217 + objects[nr].name = name;
218 + array->nr = ++nr;
219 +}
object.h
+12 -1
@@ -4,7 +4,6 @@
4 struct object_list {
5 struct object *item;
6 struct object_list *next;
7 - const char *name;
7 };
8
9 struct object_refs {
@@ -13,6 +12,15 @@ struct object_refs {
12 struct object *ref[FLEX_ARRAY]; /* more */
13 };
14
15 +struct object_array {
16 + unsigned int nr;
17 + unsigned int alloc;
18 + struct object_array_entry {
19 + struct object *item;
20 + const char *name;
21 + } *objects;
22 +};
23 +
24 #define TYPE_BITS 3
25 #define FLAG_BITS 27
26
@@ -72,4 +80,7 @@ unsigned object_list_length(struct object_list *list);
80
81 int object_list_contains(struct object_list *list, struct object *obj);
82
83 +/* Object array handling .. */
84 +void add_object_array(struct object *obj, const char *name, struct object_array *array);
85 +
86 #endif /* OBJECT_H */
revision.c
+15 -18
@@ -31,17 +31,12 @@ static char *path_name(struct name_path *path, const char *name)
31 return n;
32 }
33
34 -struct object_list **add_object(struct object *obj,
35 - struct object_list **p,
36 - struct name_path *path,
37 - const char *name)
34 +void add_object(struct object *obj,
35 + struct object_array *p,
36 + struct name_path *path,
37 + const char *name)
38 {
39 - struct object_list *entry = xmalloc(sizeof(*entry));
40 - entry->item = obj;
41 - entry->next = *p;
42 - entry->name = path_name(path, name);
43 - *p = entry;
44 - return &entry->next;
39 + add_object_array(obj, path_name(path, name), p);
40 }
41
42 static void mark_blob_uninteresting(struct blob *blob)
@@ -117,9 +112,9 @@ void mark_parents_uninteresting(struct commit *commit)
112 }
113 }
114
120 -static void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
115 +void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
116 {
122 - add_object(obj, &revs->pending_objects, NULL, name);
117 + add_object_array(obj, name, &revs->pending);
118 }
119
120 static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
@@ -836,7 +831,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
831 object = get_reference(revs, arg, sha1, flags ^ local_flags);
832 add_pending_object(revs, object, arg);
833 }
839 - if (def && !revs->pending_objects) {
834 + if (def && !revs->pending.nr) {
835 unsigned char sha1[20];
836 struct object *object;
837 if (get_sha1(def, sha1))
@@ -868,11 +863,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
863
864 void prepare_revision_walk(struct rev_info *revs)
865 {
871 - struct object_list *list;
866 + int nr = revs->pending.nr;
867 + struct object_array_entry *list = revs->pending.objects;
868
873 - list = revs->pending_objects;
874 - revs->pending_objects = NULL;
875 - while (list) {
869 + revs->pending.nr = 0;
870 + revs->pending.alloc = 0;
871 + revs->pending.objects = NULL;
872 + while (--nr >= 0) {
873 struct commit *commit = handle_commit(revs, list->item, list->name);
874 if (commit) {
875 if (!(commit->object.flags & SEEN)) {
@@ -880,7 +877,7 @@ void prepare_revision_walk(struct rev_info *revs)
877 insert_by_date(commit, &revs->commits);
878 }
879 }
883 - list = list->next;
880 + list++;
881 }
882
883 if (revs->no_walk)
revision.h
+7 -5
@@ -18,7 +18,7 @@ typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
18 struct rev_info {
19 /* Starting list */
20 struct commit_list *commits;
21 - struct object_list *pending_objects;
21 + struct object_array pending;
22
23 /* Basic information */
24 const char *prefix;
@@ -99,9 +99,11 @@ struct name_path {
99 const char *elem;
100 };
101
102 -extern struct object_list **add_object(struct object *obj,
103 - struct object_list **p,
104 - struct name_path *path,
105 - const char *name);
102 +extern void add_object(struct object *obj,
103 + struct object_array *p,
104 + struct name_path *path,
105 + const char *name);
106 +
107 +extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
108
109 #endif