{"thread":{"id":"18721","subject":"[PATCH 3/4] bisect: use the new generic \"sha1_pos\" function to lookup sha1","startedAt":"2009-04-04T20:59:36Z","lastAt":"2009-04-04T20:59:36Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"110346","messageId":"20090404225936.cdcad81b.chriscool@tuxfamily.org","threadId":"18721","inReplyTo":null,"subject":"[PATCH 3/4] bisect: use the new generic \"sha1_pos\" function to lookup sha1","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-04-04T20:59:36Z","receivedAt":"2009-04-04T20:59:36Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"instead of the specific one that was simpler but less efficient.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n bisect.c |   23 +++++++++--------------\n 1 files changed, 9 insertions(+), 14 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex affba41..336d611 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -5,6 +5,7 @@\n #include \"refs.h\"\n #include \"list-objects.h\"\n #include \"quote.h\"\n+#include \"sha1-lookup.h\"\n #include \"bisect.h\"\n \n \n@@ -461,22 +462,16 @@ static void prepare_skipped(void)\n \tqsort(skipped_sha1, skipped_sha1_nr, sizeof(*skipped_sha1), skipcmp);\n }\n \n+static const unsigned char *skipped_sha1_access(size_t index, void *table)\n+{\n+\tunsigned char (*skipped)[20] = table;\n+\treturn skipped[index];\n+}\n+\n static int lookup_skipped(unsigned char *sha1)\n {\n-\tint lo, hi;\n-\tlo = 0;\n-\thi = skipped_sha1_nr;\n-\twhile (lo < hi) {\n-\t\tint mi = (lo + hi) / 2;\n-\t\tint cmp = hashcmp(sha1, skipped_sha1[mi]);\n-\t\tif (!cmp)\n-\t\t\treturn mi;\n-\t\tif (cmp < 0)\n-\t\t\thi = mi;\n-\t\telse\n-\t\t\tlo = mi + 1;\n-\t}\n-\treturn -lo - 1;\n+\treturn sha1_pos(sha1, skipped_sha1, skipped_sha1_nr,\n+\t\t\tskipped_sha1_access);\n }\n \n struct commit_list *filter_skipped(struct commit_list *list,\n-- \n1.6.2.2.404.ge96f3.dirty\n"}]}