From: Yoshioka Tsuneo <yoshiokatsuneo@gmail.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: [PATCH] diffcore-delta: optimize renames and copies detection (git diff -M/-C)
Date: Wed, 9 Oct 2013 13:27:23 +0300 [thread overview]
Message-ID: <50C898B5-8B7A-420B-AB35-7D7776DD9920@gmail.com> (raw)
diffcore_count_changes() can return -1 when src_copied is greater than
delta_limit, without counting all the src_copied.
By that, performance of "diff -M/-C" can be improved.
Signed-off-by: Tsuneo Yoshioka <yoshiokatsuneo@gmail.com>
---
diffcore-delta.c | 11 ++++++++---
diffcore-rename.c | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/diffcore-delta.c b/diffcore-delta.c
index 7cf431d..0a9290e 100644
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
@@ -173,7 +173,7 @@ int diffcore_count_changes(struct diff_filespec *src,
{
struct spanhash *s, *d;
struct spanhash_top *src_count, *dst_count;
- unsigned long sc, la;
+ unsigned long sc, not_sc, la;
src_count = dst_count = NULL;
if (src_count_p)
@@ -190,7 +190,7 @@ int diffcore_count_changes(struct diff_filespec *src,
if (dst_count_p)
*dst_count_p = dst_count;
}
- sc = la = 0;
+ sc = not_sc = la = 0;
s = src_count->data;
d = dst_count->data;
@@ -214,8 +214,13 @@ int diffcore_count_changes(struct diff_filespec *src,
la += dst_cnt - src_cnt;
sc += src_cnt;
}
- else
+ else{
sc += dst_cnt;
+ not_sc += (src_cnt - dst_cnt);
+ if(delta_limit != 0 && not_sc > delta_limit){
+ return -1;
+ }
+ }
s++;
}
while (d->cnt) {
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 6c7a72f..d52b2c8 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -181,7 +181,7 @@ static int estimate_similarity(struct diff_filespec *src,
return 0;
delta_limit = (unsigned long)
- (base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
+ (max_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
if (diffcore_count_changes(src, dst,
&src->cnt_data, &dst->cnt_data,
delta_limit,
--
1.7.12.4 (Apple Git-37)
reply other threads:[~2013-10-09 10:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=50C898B5-8B7A-420B-AB35-7D7776DD9920@gmail.com \
--to=yoshiokatsuneo@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).