Skip to content

Commit 336d016

Browse files
Link-the-elfMike
andauthored
_distance return refactor (#9796)
Co-authored-by: Mike <[email protected]>
1 parent d31ccf3 commit 336d016

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/svelte/src/compiler/phases/1-parse/utils/fuzzymatch.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ function _distance(str1, str2) {
3333
str2 = String(str2);
3434

3535
const distance = levenshtein(str1, str2);
36-
if (str1.length > str2.length) {
37-
return 1 - distance / str1.length;
38-
} else {
39-
return 1 - distance / str2.length;
40-
}
36+
return 1 - distance / Math.max(str1.length, str2.length);
4137
}
4238

4339
// helper functions

0 commit comments

Comments
 (0)