appendFoldedRange returns the result of appending the range lo-hi and its case folding-equivalent runes to the class r.
(r []rune, lo, hi rune)
| 83 | // appendFoldedRange returns the result of appending the range lo-hi |
| 84 | // and its case folding-equivalent runes to the class r. |
| 85 | func appendFoldedRange(r []rune, lo, hi rune) []rune { |
| 86 | // Optimizations. |
| 87 | if lo <= minFold && hi >= maxFold { |
| 88 | // Range is full: folding can't add more. |
| 89 | return appendRange(r, lo, hi) |
| 90 | } |
| 91 | if hi < minFold || lo > maxFold { |
| 92 | // Range is outside folding possibilities. |
| 93 | return appendRange(r, lo, hi) |
| 94 | } |
| 95 | if lo < minFold { |
| 96 | // [lo, minFold-1] needs no folding. |
| 97 | r = appendRange(r, lo, minFold-1) |
| 98 | lo = minFold |
| 99 | } |
| 100 | if hi > maxFold { |
| 101 | // [maxFold+1, hi] needs no folding. |
| 102 | r = appendRange(r, maxFold+1, hi) |
| 103 | hi = maxFold |
| 104 | } |
| 105 | |
| 106 | // Brute force. Depend on appendRange to coalesce ranges on the fly. |
| 107 | for c := lo; c <= hi; c++ { |
| 108 | r = appendRange(r, c, c) |
| 109 | f := unicode.SimpleFold(c) |
| 110 | for f != c { |
| 111 | r = appendRange(r, f, f) |
| 112 | f = unicode.SimpleFold(f) |
| 113 | } |
| 114 | } |
| 115 | return r |
| 116 | } |
| 117 | |
| 118 | // ranges implements sort.Interface on a []rune. |
| 119 | // The choice of receiver type definition is strange |
no test coverage detected
searching dependent graphs…