MCPcopy Create free account
hub / github.com/google/re2j / appendFoldedRange

Method appendFoldedRange

java/com/google/re2j/CharClass.java:133–162  ·  view source on GitHub ↗
(int lo, int hi)

Source from the content-addressed store, hash-verified

131 // appendFoldedRange() appends the range [lo-hi] and its case
132 // folding-equivalent runes to this CharClass.
133 CharClass appendFoldedRange(int lo, int hi) {
134 // Optimizations.
135 if (lo <= Unicode.MIN_FOLD && hi >= Unicode.MAX_FOLD) {
136 // Range is full: folding can't add more.
137 return appendRange(lo, hi);
138 }
139 if (hi < Unicode.MIN_FOLD || lo > Unicode.MAX_FOLD) {
140 // Range is outside folding possibilities.
141 return appendRange(lo, hi);
142 }
143 if (lo < Unicode.MIN_FOLD) {
144 // [lo, minFold-1] needs no folding.
145 appendRange(lo, Unicode.MIN_FOLD - 1);
146 lo = Unicode.MIN_FOLD;
147 }
148 if (hi > Unicode.MAX_FOLD) {
149 // [maxFold+1, hi] needs no folding.
150 appendRange(Unicode.MAX_FOLD + 1, hi);
151 hi = Unicode.MAX_FOLD;
152 }
153
154 // Brute force. Depend on appendRange to coalesce ranges on the fly.
155 for (int c = lo; c <= hi; c++) {
156 appendRange(c, c);
157 for (int f = Unicode.simpleFold(c); f != c; f = Unicode.simpleFold(f)) {
158 appendRange(f, f);
159 }
160 }
161 return this;
162 }
163
164 // appendClass() appends the class |x| to this CharClass.
165 // It assumes |x| is clean. Does not mutate |x|.

Callers 4

appendLiteralMethod · 0.95
appendFoldedClassMethod · 0.95
parseClassMethod · 0.95
testAppendFoldedRangeMethod · 0.80

Calls 2

appendRangeMethod · 0.95
simpleFoldMethod · 0.95

Tested by 1

testAppendFoldedRangeMethod · 0.64