Source file
test/fixedbugs/issue56777.go
1
2
3
4
5
6
7 package p
8
9 func fn(setText []rune, negate bool) int {
10 ranges := []singleRange{}
11
12 if len(setText) > 0 {
13 fillFirst := false
14 l := len(setText)
15 if negate {
16 if setText[0] == 0 {
17 setText = setText[1:]
18 } else {
19 l++
20 fillFirst = true
21 }
22 }
23
24 if l%2 == 0 {
25 ranges = make([]singleRange, l/2)
26 } else {
27 ranges = make([]singleRange, l/2+1)
28 }
29
30 first := true
31 if fillFirst {
32 ranges[0] = singleRange{first: 0}
33 first = false
34 }
35
36 i := 0
37 for _, r := range setText {
38 if first {
39
40 ranges[i] = singleRange{first: r}
41 first = false
42 } else {
43 ranges[i].last = r - 1
44 i++
45 first = true
46 }
47 }
48 }
49
50 return len(ranges)
51 }
52
53 type singleRange struct {
54 first rune
55 last rune
56 }
57
View as plain text