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

Method appendRange

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

Source from the content-addressed store, hash-verified

100
101 // appendRange() appends the range [lo-hi] (inclusive) to this CharClass.
102 CharClass appendRange(int lo, int hi) {
103 // Expand last range or next to last range if it overlaps or abuts.
104 // Checking two ranges helps when appending case-folded
105 // alphabets, so that one range can be expanding A-Z and the
106 // other expanding a-z.
107 if (len > 0) {
108 for (int i = 2; i <= 4; i += 2) { // twice, using i=2, i=4
109 if (len >= i) {
110 int rlo = r[len - i];
111 int rhi = r[len - i + 1];
112 if (lo <= rhi + 1 && rlo <= hi + 1) {
113 if (lo < rlo) {
114 r[len - i] = lo;
115 }
116 if (hi > rhi) {
117 r[len - i + 1] = hi;
118 }
119 return this;
120 }
121 }
122 }
123 }
124 // Can't coalesce; append. Expand capacity by doubling as needed.
125 ensureCapacity(len + 2);
126 r[len++] = lo;
127 r[len++] = hi;
128 return this;
129 }
130
131 // appendFoldedRange() appends the range [lo-hi] and its case
132 // folding-equivalent runes to this CharClass.

Callers 8

appendLiteralMethod · 0.95
appendFoldedRangeMethod · 0.95
appendClassMethod · 0.95
appendNegatedClassMethod · 0.95
appendTableMethod · 0.95
appendNegatedTableMethod · 0.95
parseClassMethod · 0.95

Calls 1

ensureCapacityMethod · 0.95

Tested by 1