appendRange returns the result of appending the range lo-hi to the class r.
(r []rune, lo, hi rune)
| 50 | |
| 51 | // appendRange returns the result of appending the range lo-hi to the class r. |
| 52 | func appendRange(r []rune, lo, hi rune) []rune { |
| 53 | // Expand last range or next to last range if it overlaps or abuts. |
| 54 | // Checking two ranges helps when appending case-folded |
| 55 | // alphabets, so that one range can be expanding A-Z and the |
| 56 | // other expanding a-z. |
| 57 | n := len(r) |
| 58 | for i := 2; i <= 4; i += 2 { // twice, using i=2, i=4 |
| 59 | if n >= i { |
| 60 | rlo, rhi := r[n-i], r[n-i+1] |
| 61 | if lo <= rhi+1 && rlo <= hi+1 { |
| 62 | if lo < rlo { |
| 63 | r[n-i] = lo |
| 64 | } |
| 65 | if hi > rhi { |
| 66 | r[n-i+1] = hi |
| 67 | } |
| 68 | return r |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return append(r, lo, hi) |
| 74 | } |
| 75 | |
| 76 | const ( |
| 77 | // minimum and maximum runes involved in folding. |
no outgoing calls
no test coverage detected
searching dependent graphs…