Skip to content

Commit b81dcb0

Browse files
committed
fix: speedup levenshtein comparison, fixes #1087
1 parent 73eeb4e commit b81dcb0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/reconciler/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ const getTypeOf = type => {
1717
return 'Fragment'; // ?
1818
};
1919

20+
function clearStringFast(str) {
21+
return str.length < 12 ? str : ` ${str}`.slice(1);
22+
}
23+
2024
const haveTextSimilarity = (a, b) =>
2125
// equal or slight changed
22-
a === b || levenshtein.get(a, b) < a.length * 0.2;
26+
a === b || levenshtein.get(clearStringFast(a), clearStringFast(b)) < a.length * 0.2;
2327

2428
const getBaseProto = source =>
2529
source.prototype.hotComponentRender ? Object.getPrototypeOf(source.prototype) : source.prototype;

0 commit comments

Comments
 (0)