Skip to content

Commit

Permalink
fix: speedup levenshtein comparison, fixes #1087
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Aug 27, 2019
1 parent 73eeb4e commit 28b8992
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/reconciler/utils.js
Expand Up @@ -17,9 +17,13 @@ const getTypeOf = type => {
return 'Fragment'; // ?
};

function clearStringFast(str) {
return str.length < 12 ? str : (' ' + str).slice(1);
}

const haveTextSimilarity = (a, b) =>
// equal or slight changed
a === b || levenshtein.get(a, b) < a.length * 0.2;
a === b || levenshtein.get(clearStringFast(a), clearStringFast(b)) < a.length * 0.2;

const getBaseProto = source =>
source.prototype.hotComponentRender ? Object.getPrototypeOf(source.prototype) : source.prototype;
Expand Down

0 comments on commit 28b8992

Please sign in to comment.