File tree 2 files changed +7
-22
lines changed
server/inspections/compiler
tests/testdata/benchmarks
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 {
23
23
24
24
first_line := lines.first ()
25
25
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: ...`
30
27
mut filepath := first_line[..line_colon_idx]
31
28
$if windows {
32
29
filepath = filepath.replace ('/' , '\\ ' )
33
30
}
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 }
40
34
41
35
line_nr := first_line[line_colon_idx + 1 ..col_colon_idx].int () - 1
42
36
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 {
362
362
}
363
363
mut idx := 0
364
364
for {
365
- idx = s.index_after(rep, idx)
366
- if idx == -1 {
367
- break
368
- }
365
+ idx = s.index_after(rep, idx) or { break }
369
366
idxs << idx
370
367
idx += rep.len
371
368
}
@@ -438,10 +435,7 @@ pub fn (s string) replace_each(vals []string) string {
438
435
with := vals[rep_i + 1]
439
436
440
437
for {
441
- idx = s_.index_after(rep, idx)
442
- if idx == -1 {
443
- break
444
- }
438
+ idx = s_.index_after(rep, idx) or { break }
445
439
// The string already found is set to `/del`, to avoid duplicate searches.
446
440
for i in 0 .. rep.len {
447
441
unsafe {
@@ -1395,10 +1389,7 @@ pub fn (s string) count(substr string) int {
1395
1389
1396
1390
mut i := 0
1397
1391
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 }
1402
1393
i += substr.len
1403
1394
n++
1404
1395
}
You can’t perform that action at this time.
0 commit comments