From b8b72580a74380ef4f04a3deba845ddec3a55ee6 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Mon, 4 Nov 2019 22:35:28 +1100 Subject: [PATCH] compiler: typo detection - fix error & slightly optimize function --- vlib/compiler/table.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/compiler/table.v b/vlib/compiler/table.v index cf99d6a923..ad72137490 100644 --- a/vlib/compiler/table.v +++ b/vlib/compiler/table.v @@ -907,9 +907,10 @@ fn (p &Parser) identify_typo(name string) string { fn typo_compare_name_mod(a, b, b_mod string) f32 { if a.len - b.len > 2 || b.len - a.len > 2 { return 0 } auidx := a.index('__') + buidx := b.index('__') a_mod := if auidx != -1 { mod_gen_name_rev(a[..auidx]) } else { '' } - a_name := if auidx != -1 { a[auidx..] } else { a } - b_name := if b.contains('__') { b.all_after('__') } else { b } + a_name := if auidx != -1 { a[auidx+2..] } else { a } + b_name := if buidx != -1 { b[buidx+2..] } else { b } if a_mod.len > 0 && b_mod.len > 0 && a_mod != b_mod { return 0 } return strings.dice_coefficient(a_name, b_name) }