Merge branch 'rs/list-optim'
authorJunio C Hamano <gitster@pobox.com>
Thu, 11 Sep 2014 17:33:35 +0000 (10:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Sep 2014 17:33:35 +0000 (10:33 -0700)
Fix a couple of "accumulate into a sorted list" to "accumulate and
then sort the list".

* rs/list-optim:
walker: avoid quadratic list insertion in mark_complete
sha1_name: avoid quadratic list insertion in handle_one_ref

1  2 
sha1_name.c
walker.c
diff --cc sha1_name.c
Simple merge
diff --cc walker.c
index b929dcc6c043cc69b07846c16fb8aeb021aa3ae3,0b5ee3c92e5ebc2a04215b4181d04123091e02f3..f8d370913a8dcfb87d62ab994b4823dc84157f8b
+++ b/walker.c
@@@ -260,15 -258,21 +260,18 @@@ int walker_fetch(struct walker *walker
  
        save_commit_buffer = 0;
  
 -      for (i = 0; i < targets; i++) {
 -              if (!write_ref || !write_ref[i])
 -                      continue;
 -
 -              lock[i] = lock_ref_sha1(write_ref[i], NULL);
 -              if (!lock[i]) {
 -                      error("Can't lock ref %s", write_ref[i]);
 -                      goto unlock_and_fail;
 +      if (write_ref) {
 +              transaction = ref_transaction_begin(&err);
 +              if (!transaction) {
 +                      error("%s", err.buf);
 +                      goto done;
                }
        }
-       if (!walker->get_recover)
+       if (!walker->get_recover) {
                for_each_ref(mark_complete, NULL);
+               commit_list_sort_by_date(&complete);
+       }
  
        for (i = 0; i < targets; i++) {
                if (interpret_target(walker, target[i], &sha1[20 * i])) {