From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 4/4] replace_object: use the new generic "sha1_pos" function to lookup sha1
Date: Sat, 4 Apr 2009 22:59:41 +0200 [thread overview]
Message-ID: <20090404225941.7fef76a7.chriscool@tuxfamily.org> (raw)
instead of the specific one that was simpler but less efficient.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
replace_object.c | 24 +++++++++---------------
1 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/replace_object.c b/replace_object.c
index 1227214..eb59604 100644
--- a/replace_object.c
+++ b/replace_object.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "sha1-lookup.h"
#include "refs.h"
static struct replace_object {
@@ -7,23 +8,16 @@ static struct replace_object {
static int replace_object_alloc, replace_object_nr;
+static const unsigned char *replace_sha1_access(size_t index, void *table)
+{
+ struct replace_object **replace = table;
+ return replace[index]->sha1[0];
+}
+
static int replace_object_pos(const unsigned char *sha1)
{
- int lo, hi;
- lo = 0;
- hi = replace_object_nr;
- while (lo < hi) {
- int mi = (lo + hi) / 2;
- struct replace_object *rep = replace_object[mi];
- int cmp = hashcmp(sha1, rep->sha1[0]);
- if (!cmp)
- return mi;
- if (cmp < 0)
- hi = mi;
- else
- lo = mi + 1;
- }
- return -lo - 1;
+ return sha1_pos(sha1, replace_object, replace_object_nr,
+ replace_sha1_access);
}
static int register_replace_object(struct replace_object *replace,
--
1.6.2.2.404.ge96f3.dirty
next reply other threads:[~2009-04-04 21:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-04 20:59 Christian Couder [this message]
2009-04-05 13:19 ` [PATCH 4/4] replace_object: use the new generic "sha1_pos" function to lookup sha1 Johannes Schindelin
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=20090404225941.7fef76a7.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=Johannes.Schindelin@gmx.de \
--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).