1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler/vlib: replace substr/left/right with [start..end] everywhere

This commit is contained in:
joe-conigliaro
2019-10-27 18:03:15 +11:00
committed by Alexander Medvednikov
parent ed55826686
commit 59378dce46
49 changed files with 308 additions and 306 deletions

View File

@@ -44,13 +44,13 @@ pub fn dice_coefficient(s1, s2 string) f32 {
b := if a == s1 { s2 } else { s1 }
mut first_bigrams := map[string]int
for i := 0; i < a.len-1; i++ {
bigram := a.substr(i, i+2)
bigram := a[i..i+2]
q := if bigram in first_bigrams { first_bigrams[bigram]+1 } else { 1 }
first_bigrams[bigram] = q
}
mut intersection_size := 0
for i := 0; i < b.len-1; i++ {
bigram := b.substr(i, i+2)
bigram := b[i..i+2]
count := if bigram in first_bigrams { first_bigrams[bigram] } else { 0 }
if count > 0 {
first_bigrams[bigram] = count - 1