From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 07/10] bisect: automatically sort sha1_array if needed when looking it up
Date: Sat, 09 May 2009 17:55:44 +0200 [thread overview]
Message-ID: <20090509155548.5387.70784.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20090509154419.5324.96204.chriscool@tuxfamily.org>
This makes sha1_array easier to use, so later patches will be simpler.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/bisect.c b/bisect.c
index 77edeca..d2a34d1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -13,6 +13,7 @@ struct sha1_array {
unsigned char (*sha1)[20];
int sha1_nr;
int sha1_alloc;
+ int sorted;
};
static struct sha1_array good_revs;
@@ -487,6 +488,8 @@ static int array_cmp(const void *a, const void *b)
static void sort_sha1_array(struct sha1_array *array)
{
qsort(array->sha1, array->sha1_nr, sizeof(*array->sha1), array_cmp);
+
+ array->sorted = 1;
}
static const unsigned char *sha1_access(size_t index, void *table)
@@ -498,6 +501,9 @@ static const unsigned char *sha1_access(size_t index, void *table)
static int lookup_sha1_array(struct sha1_array *array,
const unsigned char *sha1)
{
+ if (!array->sorted)
+ sort_sha1_array(array);
+
return sha1_pos(sha1, array->sha1, array->sha1_nr, sha1_access);
}
@@ -512,8 +518,6 @@ struct commit_list *filter_skipped(struct commit_list *list,
if (!skipped_revs.sha1_nr)
return list;
- sort_sha1_array(&skipped_revs);
-
while (list) {
struct commit_list *next = list->next;
list->next = NULL;
--
1.6.3.rc1.112.g17e25
next prev parent reply other threads:[~2009-05-09 16:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-09 15:55 [PATCH 00/10] bisect: port git bisect merge base checking to C Christian Couder
2009-05-09 15:55 ` [PATCH 01/10] bisect: use "sha1_array" to store skipped revisions Christian Couder
2009-05-09 15:55 ` [PATCH 02/10] bisect: implement "rev_argv_push" to fill an argv with revs Christian Couder
2009-05-09 15:55 ` [PATCH 03/10] bisect: store good revisions in a "sha1_array" Christian Couder
2009-05-09 15:55 ` [PATCH 04/10] bisect: use new "struct argv_array" to prepare argv for "setup_revisions" Christian Couder
2009-05-09 15:55 ` [PATCH 05/10] bisect: remove too much function nesting Christian Couder
2009-05-09 15:55 ` [PATCH 06/10] bisect: make skipped array functions more generic Christian Couder
2009-05-09 15:55 ` Christian Couder [this message]
2009-05-09 16:28 ` [PATCH 07/10] bisect: automatically sort sha1_array if needed when looking it up Jakub Narebski
2009-05-10 4:44 ` Christian Couder
2009-05-09 15:55 ` [PATCH 08/10] bisect: implement the "check_merge_bases" function Christian Couder
2009-05-09 15:55 ` [PATCH 09/10] bisect: add "check_good_are_ancestors_of_bad" function Christian Couder
2009-05-09 15:55 ` [PATCH 10/10] bisect: make "git bisect" use new "--next-all" bisect-helper function Christian Couder
2009-05-11 0:44 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090509155548.5387.70784.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).