Skip to content

Commit c847baa

Browse files
derrickstoleedscho
authored andcommitted
path-walk: improve path-walk speed with many tags
In the presence of many tags, the use of oid_array_lookup() can become extremely slow. We should rely upon the SEEN bit instead. This affects the tag-peeling walk as well as the switch statement for adding the peeled object to the correct oid_array. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 31789fd commit c847baa

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

path-walk.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -299,26 +299,28 @@ int walk_objects_by_path(struct path_walk_info *info)
299299
if (obj->type == OBJ_COMMIT || obj->flags & SEEN)
300300
continue;
301301

302-
obj->flags |= SEEN;
303-
304302
while (obj->type == OBJ_TAG) {
305303
struct tag *tag = lookup_tag(info->revs->repo,
306304
&obj->oid);
307-
if (oid_array_lookup(&tags, &obj->oid) < 0)
305+
if (!(obj->flags & SEEN)) {
306+
obj->flags |= SEEN;
308307
oid_array_append(&tags, &obj->oid);
308+
}
309309
obj = tag->tagged;
310310
}
311311

312+
if ((obj->flags & SEEN))
313+
continue;
314+
obj->flags |= SEEN;
315+
312316
switch (obj->type) {
313317
case OBJ_TREE:
314-
if (info->trees &&
315-
oid_array_lookup(&root_tree_list->oids, &obj->oid) < 0)
318+
if (info->trees)
316319
oid_array_append(&root_tree_list->oids, &obj->oid);
317320
break;
318321

319322
case OBJ_BLOB:
320-
if (info->blobs &&
321-
oid_array_lookup(&tagged_blob_list, &obj->oid) < 0)
323+
if (info->blobs)
322324
oid_array_append(&tagged_blob_list, &obj->oid);
323325
break;
324326

0 commit comments

Comments
 (0)