Cap line matching comparisons
This commit is contained in:
parent
3929ca28fc
commit
ee494b88e5
3 changed files with 10 additions and 2 deletions
|
|
@ -67,6 +67,7 @@ The HTML output accepts a Javascript object with configuration. Possible options
|
||||||
- `showFiles`: show a file list before the diff: `true` or `false`, default is `false`
|
- `showFiles`: show a file list before the diff: `true` or `false`, default is `false`
|
||||||
- `matching`: matching level: `'lines'` for matching lines, `'words'` for matching lines and words or `'none'`, default is `none`
|
- `matching`: matching level: `'lines'` for matching lines, `'words'` for matching lines and words or `'none'`, default is `none`
|
||||||
- `matchWordsThreshold`: similarity threshold for word matching, default is 0.25
|
- `matchWordsThreshold`: similarity threshold for word matching, default is 0.25
|
||||||
|
- `matchingMaxComparisons`: perform at most this much comparisons for line matching a block of changes, default is `2500`
|
||||||
|
|
||||||
## Diff2HtmlUI Helper
|
## Diff2HtmlUI Helper
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,10 @@
|
||||||
var insertType;
|
var insertType;
|
||||||
var deleteType;
|
var deleteType;
|
||||||
|
|
||||||
var doMatching = that.config.matching === 'lines' || that.config.matching === 'words';
|
var comparisons = oldLines.length * newLines.length;
|
||||||
|
var maxComparisons = that.config.matchingMaxComparisons || 2500;
|
||||||
|
var doMatching = comparisons < maxComparisons && (that.config.matching === 'lines' ||
|
||||||
|
that.config.matching === 'words');
|
||||||
|
|
||||||
if (doMatching) {
|
if (doMatching) {
|
||||||
matches = matcher(oldLines, newLines);
|
matches = matcher(oldLines, newLines);
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,11 @@
|
||||||
var matches;
|
var matches;
|
||||||
var insertType;
|
var insertType;
|
||||||
var deleteType;
|
var deleteType;
|
||||||
var doMatching = that.config.matching === 'lines' || that.config.matching === 'words';
|
|
||||||
|
var comparisons = oldLines.length * newLines.length;
|
||||||
|
var maxComparisons = that.config.matchingMaxComparisons || 2500;
|
||||||
|
var doMatching = comparisons < maxComparisons && (that.config.matching === 'lines' ||
|
||||||
|
that.config.matching === 'words');
|
||||||
|
|
||||||
if (doMatching) {
|
if (doMatching) {
|
||||||
matches = matcher(oldLines, newLines);
|
matches = matcher(oldLines, newLines);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue