diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-08-17 13:09:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-17 13:09:57 -0700 |
commit | 791ad494835ac544d9e91573f3a65aeb97d126ed (patch) | |
tree | 03c5e9076cdf96f6efbf8d913d496f61ab45858b /xdiff | |
parent | 8ba8642bd5d89629973268ff28bc5b0b3d45e35b (diff) | |
parent | 301ef8540155316cb87c896866dd1cab3108807b (diff) | |
download | git-791ad494835ac544d9e91573f3a65aeb97d126ed.tar.gz |
Merge branch 'sb/indent-heuristic-optim'
"git diff --indent-heuristic" had a bad corner case performance.
* sb/indent-heuristic-optim:
xdiff: reduce indent heuristic overhead
Diffstat (limited to 'xdiff')
-rw-r--r-- | xdiff/xdiffi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 3e8aff92bc..1f1f4a3c78 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -575,6 +575,11 @@ static void measure_split(const xdfile_t *xdf, long split, #define INDENT_WEIGHT 60 /* + * How far do we slide a hunk at most? + */ +#define INDENT_HEURISTIC_MAX_SLIDING 100 + +/* * Compute a badness score for the hypothetical split whose measurements are * stored in m. The weight factors were determined empirically using the tools and * corpus described in @@ -886,7 +891,12 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { long shift, best_shift = -1; struct split_score best_score; - for (shift = earliest_end; shift <= g.end; shift++) { + shift = earliest_end; + if (g.end - groupsize - 1 > shift) + shift = g.end - groupsize - 1; + if (g.end - INDENT_HEURISTIC_MAX_SLIDING > shift) + shift = g.end - INDENT_HEURISTIC_MAX_SLIDING; + for (; shift <= g.end; shift++) { struct split_measurement m; struct split_score score = {0, 0}; |