Commit Graph

24 Commits

Author SHA1 Message Date
Frank LENORMAND
63092d12c0 src: Fix the build on Mac
When compiled on Mac with `clang`, the following error occurs at
compile-time:

```
./diff.hh:56:28: error: no member named 'min' in namespace 'std'
    const int max_D = std::min((M + N + 1) / 2 + 1, cost_limit);
                      ~~~~~^
```
2019-12-01 21:55:55 +01:00
Maxime Coste
4fdbf21ff8 Refactor diff to make allocating a diff vector optional
The diff interface now goes through a for_each_diff function that
uses a callback for each found diff.
2019-11-30 11:29:36 +11:00
Maxime Coste
bbf62d1779 diff: try to improve code readability 2018-02-09 21:31:10 +11:00
Maxime Coste
fdf7cf3944 Small code simplifications 2017-09-07 19:38:34 +08:00
Maxime Coste
d1c005dd8c Limit diff algorithm complexity
Return a non-optimal, but valid, diff when we detect too many
iterations

Fixes #1509
2017-07-23 21:33:12 +02:00
Maxime Coste
d43e2ac843 More cleanups in diff code 2017-07-20 17:47:50 +02:00
Maxime Coste
7b96d56996 Use the provided equal functor for prefix/suffix detection in diff
We were wrongly using the `==` operator.
2017-07-18 17:53:30 +02:00
Maxime Coste
9197dd393c More refactoring of the diff code in order to make it cleaner 2017-07-18 16:11:24 +02:00
Maxime Coste
50fec86749 Change diff Implementation to use end indices instead of length
Having absolute begin and relative lenght was a bit strange to
work with. Rename middle_snake to snake.
2017-07-18 12:14:52 +02:00
Maxime Coste
793c2ed9cf Slight style change 2017-07-17 19:29:57 +02:00
Maxime Coste
d90cd6de77 Refactor find_diff_rec and detect kept prefix/suffixes early
Certain cases, like diffing an empty buffer with a big buffer, were
very slow, now this should get better as we will directly detect the
matching eol at the end of both buffers, end then immediatly detect
we need to add the rest of the big buffer.

We still are too slow on some general diff when there is a lot of
differences.
2017-07-17 13:30:11 +02:00
Maxime Coste
388ada8142 Remove MirroredArray for diff implementation
We can index native arrays negatively, so just setup V1 and V2 to
point in the middle of the work arrays and remove the need for
creating MirroredArray.
2017-07-17 19:28:52 +09:00
Maxime Coste
5eae7aacc7 Small code cleanup in diff implementation 2017-07-15 17:17:27 +09:00
Maxime Coste
2b6fc6beb7 Remove unused Diff::posA field 2017-01-29 12:49:52 +00:00
Michael Vetter
71f6ee3234 Remove trailing whitespaces 2015-11-19 16:31:00 +01:00
Maxime Coste
c1b9ea4d1e Formatting tweak 2015-07-13 13:57:43 +01:00
Maxime Coste
9f46d75b27 Add headers guard to diff.hh along with a comment about the algorithm 2015-05-19 19:46:24 +01:00
Maxime Coste
38bbecef62 Fix bug in diff implementations (missing snake after d=1 change) and refactor 2015-05-18 22:59:59 +01:00
Maxime Coste
0a6ad4dcf4 Only initialize element 1 in mirrored arrays. 2015-05-17 20:13:11 +01:00
Maxime Coste
73ddf18dc3 Another bug fix in diff implementation 2015-05-15 13:55:39 +01:00
Maxime Coste
e9af3a4217 always_inline a few methods 2015-05-14 19:05:41 +01:00
Maxime Coste
cc97d4ba41 Fix bugs in diff implementation 2015-05-14 13:57:03 +01:00
Maxime Coste
7a8c2d7f56 Fix diff implementation and change the Diff struct format 2015-05-13 23:22:29 +01:00
Maxime Coste
49def73e4e Add initial diff implementation based Eugene W. Myers' algorithm 2015-05-12 23:41:35 +01:00