* Re: [PATCH] refactor commit_graft_pos using general sha1_pos function
2010-02-26 15:42 [PATCH] refactor commit_graft_pos using general sha1_pos function jackylee
@ 2010-02-26 3:04 ` Tay Ray Chuan
0 siblings, 0 replies; 4+ messages in thread
From: Tay Ray Chuan @ 2010-02-26 3:04 UTC (permalink / raw)
To: jackylee; +Cc: git, gitster
Hi,
On Fri, Feb 26, 2010 at 11:42 PM, jackylee <jacky.liye@gmail.com> wrote:
> code cleanup according to git janitor page, replace sha1 lookup function with "sha1_pos" general binary search function
>
> Signed-off-by: jacky.liye <jacky.liye@gmail.com>
please sign off with your real name. See
http://repo.or.cz/w/git.git?a=blob;f=Documentation/SubmittingPatches;hb=HEAD
for the importance of the sign-off.
--
Cheers,
Ray Chuan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] refactor commit_graft_pos using general sha1_pos function
@ 2010-02-26 15:42 jackylee
2010-02-26 3:04 ` Tay Ray Chuan
0 siblings, 1 reply; 4+ messages in thread
From: jackylee @ 2010-02-26 15:42 UTC (permalink / raw)
To: git; +Cc: gitster
code cleanup according to git janitor page, replace sha1 lookup function with "sha1_pos" general binary search function
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] refactor commit_graft_pos using general sha1_pos function
@ 2010-02-26 16:31 jackylee
0 siblings, 0 replies; 4+ messages in thread
From: jackylee @ 2010-02-26 16:31 UTC (permalink / raw)
To: git; +Cc: gitster, rctay89
thanks, please ignore the previous mail.
code cleanup according to git janitor page, replace sha1 lookup function with "sha1_pos" general binary search function
Signed-off-by: Li Ye <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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] refactor commit_graft_pos using general sha1_pos function
@ 2010-02-25 19:57 jacky.liye
0 siblings, 0 replies; 4+ messages in thread
From: jacky.liye @ 2010-02-25 19:57 UTC (permalink / raw)
To: git; +Cc: jackylee
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-26 3:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-26 15:42 [PATCH] refactor commit_graft_pos using general sha1_pos function jackylee
2010-02-26 3:04 ` Tay Ray Chuan
-- strict thread matches above, loose matches on Subject: below --
2010-02-26 16:31 jackylee
2010-02-25 19:57 jacky.liye
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.