fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fdb9aae
)
Optimization.
author
Radek Czajka
<rczajka@rczajka.pl>
Thu, 20 Jul 2023 22:46:22 +0000
(
00:46
+0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Thu, 20 Jul 2023 22:46:22 +0000
(
00:46
+0200)
src/redakcja/static/js/lib/diff.js
patch
|
blob
|
history
diff --git
a/src/redakcja/static/js/lib/diff.js
b/src/redakcja/static/js/lib/diff.js
index
4dda274
..
2ba23ce
100644
(file)
--- a/
src/redakcja/static/js/lib/diff.js
+++ b/
src/redakcja/static/js/lib/diff.js
@@
-18,10
+18,25
@@
$.wiki.diff = function(a, b) {
x = Vp[k - 1] + 1;
}
y = x - k;
x = Vp[k - 1] + 1;
}
y = x - k;
+
while (x < N && y < M && a[x] == b[y]) {
x ++;
y ++;
while (x < N && y < M && a[x] == b[y]) {
x ++;
y ++;
+
+ // Avoid comparing long text character by character.
+ let step = 1;
+ while (true) {
+ step = Math.min(step * 2, N - x, M - y);
+ if (!step) break;
+ if (a.substr(x, step) == b.substr(y, step)) {
+ x += step;
+ y += step;
+ } else {
+ break;
+ }
+ }
}
}
+
V[k] = x;
if (x == N && y == M) {
endD = D;
V[k] = x;
if (x == N && y == M) {
endD = D;
@@
-36,7
+51,7
@@
$.wiki.diff = function(a, b) {
// Now go back.
result = []
// Now go back.
result = []
- let
snake,
px, py;
+ let px, py;
for (D = endD; D; --D) {
k = x - y;
V = VV[D - 1];
for (D = endD; D; --D) {
k = x - y;
V = VV[D - 1];