File tree Expand file tree Collapse file tree 2 files changed +7
-22
lines changed
server/inspections/compiler
tests/testdata/benchmarks Expand file tree Collapse file tree 2 files changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,14 @@ fn parse_compiler_diagnostic(msg string) ?inspections.Report {
2323
2424 first_line := lines.first ()
2525
26- line_colon_idx := first_line.index_after (':' , 2 ) // deal with `d:/v/...:2:4: error: ...`
27- if line_colon_idx < 0 {
28- return none
29- }
26+ line_colon_idx := first_line.index_after (':' , 2 ) or { return none } // deal with `d:/v/...:2:4: error: ...`
3027 mut filepath := first_line[..line_colon_idx]
3128 $if windows {
3229 filepath = filepath.replace ('/' , '\\ ' )
3330 }
34- col_colon_idx := first_line.index_after (':' , line_colon_idx + 1 )
35- colon_sep_idx := first_line.index_after (':' , col_colon_idx + 1 )
36- msg_type_colon_idx := first_line.index_after (':' , colon_sep_idx + 1 )
37- if msg_type_colon_idx == - 1 || col_colon_idx == - 1 || colon_sep_idx == - 1 {
38- return none
39- }
31+ col_colon_idx := first_line.index_after (':' , line_colon_idx + 1 ) or { return none }
32+ colon_sep_idx := first_line.index_after (':' , col_colon_idx + 1 ) or { return none }
33+ msg_type_colon_idx := first_line.index_after (':' , colon_sep_idx + 1 ) or { return none }
4034
4135 line_nr := first_line[line_colon_idx + 1 ..col_colon_idx].int () - 1
4236 col_nr := first_line[col_colon_idx + 1 ..colon_sep_idx].int () - 1
Original file line number Diff line number Diff line change @@ -362,10 +362,7 @@ pub fn (s string) replace(rep string, with string) string {
362362 }
363363 mut idx := 0
364364 for {
365- idx = s.index_after(rep, idx)
366- if idx == -1 {
367- break
368- }
365+ idx = s.index_after(rep, idx) or { break }
369366 idxs << idx
370367 idx += rep.len
371368 }
@@ -438,10 +435,7 @@ pub fn (s string) replace_each(vals []string) string {
438435 with := vals[rep_i + 1]
439436
440437 for {
441- idx = s_.index_after(rep, idx)
442- if idx == -1 {
443- break
444- }
438+ idx = s_.index_after(rep, idx) or { break }
445439 // The string already found is set to `/del`, to avoid duplicate searches.
446440 for i in 0 .. rep.len {
447441 unsafe {
@@ -1395,10 +1389,7 @@ pub fn (s string) count(substr string) int {
13951389
13961390 mut i := 0
13971391 for {
1398- i = s.index_after(substr, i)
1399- if i == -1 {
1400- return n
1401- }
1392+ i = s.index_after(substr, i) or { return n }
14021393 i += substr.len
14031394 n++
14041395 }
You can’t perform that action at this time.
0 commit comments