{"thread":{"id":"35089","subject":"[PATCH] diffcore-delta: optimize renames and copies detection (git diff -M/-C)","startedAt":"2013-10-09T10:27:23Z","lastAt":"2013-10-09T10:27:23Z","messageCount":1,"participants":["Yoshioka Tsuneo"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"228638","messageId":"50C898B5-8B7A-420B-AB35-7D7776DD9920@gmail.com","threadId":"35089","inReplyTo":null,"subject":"[PATCH] diffcore-delta: optimize renames and copies detection (git diff -M/-C)","fromName":"Yoshioka Tsuneo","fromEmail":"yoshiokatsuneo@gmail.com","sentAt":"2013-10-09T10:27:23Z","receivedAt":"2013-10-09T10:27:23Z","isPatch":true,"sender":{"key":"yoshiokatsuneo@gmail.com","avatar":"https://gravatar.com/avatar/1a1dddcd048d4e847e125557e79d2cad1cbe84a9775bb0298a24a6bf687aa040?d=mp&s=160"},"body":"diffcore_count_changes() can return -1 when src_copied is greater than\ndelta_limit, without counting all the src_copied.\nBy that, performance of \"diff -M/-C\" can be improved.\n\nSigned-off-by: Tsuneo Yoshioka <yoshiokatsuneo@gmail.com>\n---\n diffcore-delta.c  | 11 ++++++++---\n diffcore-rename.c |  2 +-\n 2 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/diffcore-delta.c b/diffcore-delta.c\nindex 7cf431d..0a9290e 100644\n--- a/diffcore-delta.c\n+++ b/diffcore-delta.c\n@@ -173,7 +173,7 @@ int diffcore_count_changes(struct diff_filespec *src,\n {\n \tstruct spanhash *s, *d;\n \tstruct spanhash_top *src_count, *dst_count;\n-\tunsigned long sc, la;\n+\tunsigned long sc, not_sc, la;\n \n \tsrc_count = dst_count = NULL;\n \tif (src_count_p)\n@@ -190,7 +190,7 @@ int diffcore_count_changes(struct diff_filespec *src,\n \t\tif (dst_count_p)\n \t\t\t*dst_count_p = dst_count;\n \t}\n-\tsc = la = 0;\n+\tsc = not_sc = la = 0;\n \n \ts = src_count->data;\n \td = dst_count->data;\n@@ -214,8 +214,13 @@ int diffcore_count_changes(struct diff_filespec *src,\n \t\t\tla += dst_cnt - src_cnt;\n \t\t\tsc += src_cnt;\n \t\t}\n-\t\telse\n+\t\telse{\n \t\t\tsc += dst_cnt;\n+\t\t\tnot_sc += (src_cnt - dst_cnt);\n+\t\t\tif(delta_limit != 0 && not_sc > delta_limit){\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n \t\ts++;\n \t}\n \twhile (d->cnt) {\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 6c7a72f..d52b2c8 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -181,7 +181,7 @@ static int estimate_similarity(struct diff_filespec *src,\n \t\treturn 0;\n \n \tdelta_limit = (unsigned long)\n-\t\t(base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);\n+\t\t(max_size * (MAX_SCORE-minimum_score) / MAX_SCORE);\n \tif (diffcore_count_changes(src, dst,\n \t\t\t\t   &src->cnt_data, &dst->cnt_data,\n \t\t\t\t   delta_limit,\n-- \n1.7.12.4 (Apple Git-37)\n"}]}