* [PATCH] diffcore-delta: optimize renames and copies detection (git diff -M/-C)
@ 2013-10-09 10:27 Yoshioka Tsuneo
0 siblings, 0 replies; only message in thread
From: Yoshioka Tsuneo @ 2013-10-09 10:27 UTC (permalink / raw)
To: git@vger.kernel.org
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)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-10-09 10:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-09 10:27 [PATCH] diffcore-delta: optimize renames and copies detection (git diff -M/-C) Yoshioka Tsuneo
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).