258
if (line1.trim() === line2.trim()) { return true; }
259
if (line1.length > 300 && line2.length > 300) { return false; }
261
>
const myersDiffingAlgorithm = new MyersDiffAlgorithm();
262
>
const result = myersDiffingAlgorithm.compute(
263
>
new LinesSliceCharSequence([line1], new Range(1, 1, 1, line1.length), false),
264
>
new LinesSliceCharSequence([line2], new Range(1, 1, 1, line2.length), false),
265
>
timeout
266
>
);
267
>
let commonNonSpaceCharCount = 0;
268
>
const inverted = SequenceDiff.invert(result.diffs, line1.length);
269
>
for (const seq of inverted) {
270
>
seq.seq1Range.forEach(idx => {
271
if (!isSpace(line1.charCodeAt(idx))) {
272
commonNonSpaceCharCount++;
273
}
275
>
}
276
>
277
>
function countNonWsChars(str: string): number {
278
>
let count = 0;
279
>
for (let i = 0; i < line1.length; i++) {
280
if (!isSpace(str.charCodeAt(i))) {
281
count++;
282
}
283
}
285
>
}
286
>
287
const longerLineLength = countNonWsChars(line1.length > line2.length ? line1 : line2);
288
const r = commonNonSpaceCharCount / longerLineLength > 0.6 && longerLineLength > 10;