Show More
@@ -0,0 +1,29 b'' | |||||
|
1 | #require no-pure | |||
|
2 | ||||
|
3 | A script to generate nasty diff worst-case scenarios: | |||
|
4 | ||||
|
5 | $ cat > s.py <<EOF | |||
|
6 | > import random | |||
|
7 | > for x in xrange(100000): | |||
|
8 | ||||
|
9 | > if random.randint(0, 100) >= 50: | |||
|
10 | > x += 1 | |||
|
11 | > print hex(x) | |||
|
12 | > EOF | |||
|
13 | ||||
|
14 | $ hg init a | |||
|
15 | $ cd a | |||
|
16 | ||||
|
17 | Check in a big file: | |||
|
18 | ||||
|
19 | $ python ../s.py > a | |||
|
20 | $ hg ci -qAm0 | |||
|
21 | ||||
|
22 | Modify it: | |||
|
23 | ||||
|
24 | $ python ../s.py > a | |||
|
25 | ||||
|
26 | Time a check-in, should never take more than 10 seconds user time: | |||
|
27 | ||||
|
28 | $ hg ci --time -m1 | |||
|
29 | time: real .* secs .user [0-9][.].* sys .* (re) |
@@ -148,7 +148,7 b' static int equatelines(struct line *a, i' | |||||
148 | static int longest_match(struct line *a, struct line *b, struct pos *pos, |
|
148 | static int longest_match(struct line *a, struct line *b, struct pos *pos, | |
149 | int a1, int a2, int b1, int b2, int *omi, int *omj) |
|
149 | int a1, int a2, int b1, int b2, int *omi, int *omj) | |
150 | { |
|
150 | { | |
151 | int mi = a1, mj = b1, mk = 0, mb = 0, i, j, k; |
|
151 | int mi = a1, mj = b1, mk = 0, mb = 0, i, j, k, half = (a1 + a2) / 2; | |
152 |
|
152 | |||
153 | for (i = a1; i < a2; i++) { |
|
153 | for (i = a1; i < a2; i++) { | |
154 | /* skip all lines in b after the current block */ |
|
154 | /* skip all lines in b after the current block */ | |
@@ -165,8 +165,9 b' static int longest_match(struct line *a,' | |||||
165 | pos[j].pos = i; |
|
165 | pos[j].pos = i; | |
166 | pos[j].len = k; |
|
166 | pos[j].len = k; | |
167 |
|
167 | |||
168 |
/* best match so far? |
|
168 | /* best match so far? we prefer matches closer | |
169 | if (k > mk || (k == mk && i <= mi)) { |
|
169 | to the middle to balance recursion */ | |
|
170 | if (k > mk || (k == mk && (i <= mi || i < half))) { | |||
170 | mi = i; |
|
171 | mi = i; | |
171 | mj = j; |
|
172 | mj = j; | |
172 | mk = k; |
|
173 | mk = k; |
General Comments 0
You need to be logged in to leave comments.
Login now