]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'kn/bundle-dedup-optim'
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2025 20:58:50 +0000 (13:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2025 20:58:50 +0000 (13:58 -0700)
Optimize the code to dedup references recorded in a bundle file.

* kn/bundle-dedup-optim:
  bundle: fix non-linear performance scaling with refs
  t6020: test for duplicate refnames in bundle creation

1  2 
object.c
object.h

diff --cc object.c
index 154525a497234c1f8fab9d984752cea79f5ac688,a2c598617850a052665a59c8faa147a31839c089..d054e7f0d07b15a12b02215a638bb75d9514f052
+++ b/object.c
@@@ -492,45 -491,12 +492,12 @@@ void object_array_clear(struct object_a
        array->nr = array->alloc = 0;
  }
  
- /*
-  * Return true if array already contains an entry.
-  */
- static int contains_object(struct object_array *array,
-                          const struct object *item, const char *name)
- {
-       unsigned nr = array->nr, i;
-       struct object_array_entry *object = array->objects;
-       for (i = 0; i < nr; i++, object++)
-               if (item == object->item && !strcmp(object->name, name))
-                       return 1;
-       return 0;
- }
- void object_array_remove_duplicates(struct object_array *array)
- {
-       unsigned nr = array->nr, src;
-       struct object_array_entry *objects = array->objects;
-       array->nr = 0;
-       for (src = 0; src < nr; src++) {
-               if (!contains_object(array, objects[src].item,
-                                    objects[src].name)) {
-                       if (src != array->nr)
-                               objects[array->nr] = objects[src];
-                       array->nr++;
-               } else {
-                       object_array_release_entry(&objects[src]);
-               }
-       }
- }
 -void clear_object_flags(unsigned flags)
 +void clear_object_flags(struct repository *repo, unsigned flags)
  {
        int i;
  
-       for (i=0; i < repo->parsed_objects->obj_hash_size; i++) {
 -      for (i=0; i < the_repository->parsed_objects->obj_hash_size; i++) {
 -              struct object *obj = the_repository->parsed_objects->obj_hash[i];
++      for (i = 0; i < repo->parsed_objects->obj_hash_size; i++) {
 +              struct object *obj = repo->parsed_objects->obj_hash[i];
                if (obj)
                        obj->flags &= ~flags;
        }
diff --cc object.h
Simple merge