From: jacky.liye@gmail.com
To: git@vger.kernel.org
Cc: jackylee <jacky.liye@gmail.com>
Subject: [PATCH] refactor commit_graft_pos using general sha1_pos function
Date: Thu, 25 Feb 2010 14:57:27 -0500 [thread overview]
Message-ID: <1267127847-6172-1-git-send-email-jacky.liye@gmail.com> (raw)
From: jackylee <jacky.liye@gmail.com>
Signed-off-by: jacky.liye <jacky.liye@gmail.com>
---
commit.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/commit.c b/commit.c
index 731191e..c44d091 100644
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
#include "diff.h"
#include "revision.h"
#include "notes.h"
+#include "sha1-lookup.h"
int save_commit_buffer = 1;
@@ -78,24 +79,14 @@ static unsigned long parse_commit_date(const char *buf, const char *tail)
static struct commit_graft **commit_graft;
static int commit_graft_alloc, commit_graft_nr;
-
+static const unsigned char *commit_graft_access(size_t index, void *table)
+{
+ struct commit_graft **grafts = table;
+ return (const unsigned char *)grafts[index];
+}
static int commit_graft_pos(const unsigned char *sha1)
{
- int lo, hi;
- lo = 0;
- hi = commit_graft_nr;
- while (lo < hi) {
- int mi = (lo + hi) / 2;
- struct commit_graft *graft = commit_graft[mi];
- int cmp = hashcmp(sha1, graft->sha1);
- if (!cmp)
- return mi;
- if (cmp < 0)
- hi = mi;
- else
- lo = mi + 1;
- }
- return -lo - 1;
+ return sha1_pos(sha1, commit_graft, commit_graft_nr, commit_graft_access);
}
int register_commit_graft(struct commit_graft *graft, int ignore_dups)
--
1.6.3.3
next reply other threads:[~2010-02-25 7:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-25 19:57 jacky.liye [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-02-26 15:42 [PATCH] refactor commit_graft_pos using general sha1_pos function jackylee
2010-02-26 3:04 ` Tay Ray Chuan
2010-02-26 16:31 jackylee
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=1267127847-6172-1-git-send-email-jacky.liye@gmail.com \
--to=jacky.liye@gmail.com \
--cc=git@vger.kernel.org \
/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).