@@ -39,7 +39,7 @@ class CombinePrefixPattern {
3939 }
4040
4141 /* *
42- * Given a group of [java.util.regex.Pattern ]s, returns a `RegExp` that globally
42+ * Given a group of [Regex ]s, returns a `RegExp` that globally
4343 * matches the union of the sets of strings matched by the input RegExp.
4444 * Since it matches globally, if the input strings have a start-of-input
4545 * anchor (/^.../), it is ignored for the purposes of unioning.
@@ -53,7 +53,7 @@ class CombinePrefixPattern {
5353 var i: Int = 0
5454 val n: Int = regexs.size
5555 while (i < n) {
56- val regex: Regex = regexs.get(i)
56+ val regex: Regex = regexs[i]
5757 if (regex.options.contains(RegexOption .IGNORE_CASE )) {
5858 ignoreCase = true
5959 } else if (Util .test(
@@ -87,7 +87,7 @@ class CombinePrefixPattern {
8787 )
8888 }
8989
90- internal fun decodeEscape (charsetPart : String ): Int {
90+ private fun decodeEscape (charsetPart : String ): Int {
9191 val cc0: Int = charsetPart[0 ].code
9292 if (cc0 != 92 /* \\ */ ) {
9393 return cc0
@@ -102,7 +102,7 @@ class CombinePrefixPattern {
102102 }
103103 }
104104
105- internal fun encodeEscape (charCode : Int ): String {
105+ private fun encodeEscape (charCode : Int ): String {
106106 if (charCode < 0x20 ) {
107107 return (if (charCode < 0x10 ) " \\ x0" else " \\ x" ) + charCode.toString(16 )
108108 }
@@ -111,7 +111,7 @@ class CombinePrefixPattern {
111111 return if (((charCode == ' \\ ' .code) || (charCode == ' -' .code) || (charCode == ' ]' .code) || (charCode == ' ^' .code))) " \\ " + ch else ch
112112 }
113113
114- internal fun toChars (codePoint : Int ): CharArray {
114+ private fun toChars (codePoint : Int ): CharArray {
115115 return if (codePoint ushr 16 == 0 ) {
116116 charArrayOf(codePoint.toChar())
117117 } else if (codePoint ushr 16 < 0X10FFFF + 1 ushr 16 ) {
@@ -125,7 +125,7 @@ class CombinePrefixPattern {
125125 }
126126 }
127127
128- internal fun caseFoldCharset (charSet : String? ): String {
128+ private fun caseFoldCharset (charSet : String? ): String {
129129 val charsetParts = Util .match(
130130 Regex (
131131 (" \\\\ u[0-9A-Fa-f]{4}"
@@ -183,14 +183,14 @@ class CombinePrefixPattern {
183183
184184 // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
185185 // -> [[1, 12], [14, 14], [16, 17]]
186- ranges.sortWith( { a, b -> if (a[0 ] != b[0 ]) (a[0 ] - b[0 ]) else (b[1 ] - a[1 ]) })
186+ ranges.sortWith { a, b -> if (a[0 ] != b[0 ]) (a[0 ] - b[0 ]) else (b[1 ] - a[1 ]) }
187187// Collections.sort(ranges, Comparator { a, b -> if (a[0] !== b[0]) (a[0] - b[0]) else (b[1] - a[1]) })
188188 val consolidatedRanges: MutableList <List <Int >> = ArrayList ()
189189 // List<Integer> lastRange = listOf(new Integer[]{0, 0});
190190 var lastRange: MutableList <Int > = ArrayList (listOf (0 , 0 ))
191191 for (i in ranges.indices) {
192192 val range = ranges[i]
193- if (lastRange[ 1 ] != null && range[0 ] <= lastRange[1 ] + 1 ) {
193+ if (range[0 ] <= lastRange[1 ] + 1 ) {
194194 lastRange[1 ] = (lastRange[1 ]).coerceAtLeast(range[1 ])
195195 } else {
196196 // reference of lastRange is added
@@ -211,7 +211,7 @@ class CombinePrefixPattern {
211211 return join(out )
212212 }
213213
214- internal fun allowAnywhereFoldCaseAndRenumberGroups (regex : Regex ): String {
214+ private fun allowAnywhereFoldCaseAndRenumberGroups (regex : Regex ): String {
215215 // Split into character sets, escape sequences, punctuation strings
216216 // like ('(', '(?:', ')', '^'), and runs of characters that do not
217217 // include any of the above.
@@ -242,11 +242,11 @@ class CombinePrefixPattern {
242242 var i: Int = 0
243243 var groupIndex: Int = 0
244244 while (i < n) {
245- val p: String = parts.get(i)
245+ val p: String = parts[i]
246246 if ((p == " (" )) {
247247 // groups are 1-indexed, so max group index is count of '('
248248 ++ groupIndex
249- } else if (' \\ ' == p!! [0 ]) {
249+ } else if (' \\ ' == p[0 ]) {
250250 try {
251251 val decimalValue: Int = abs(p.substring(1 ).toInt())
252252 if (decimalValue <= groupIndex) {
@@ -275,17 +275,17 @@ class CombinePrefixPattern {
275275 var i: Int = 0
276276 var groupIndex: Int = 0
277277 while (i < n) {
278- val p: String = parts.get(i)
278+ val p: String = parts[i]
279279 if ((p == " (" )) {
280280 ++ groupIndex
281- if (capturedGroups.get( groupIndex) == null ) {
281+ if (capturedGroups[ groupIndex] == null ) {
282282 parts[i] = " (?:"
283283 }
284- } else if (' \\ ' == p!! .get( 0 ) ) {
284+ } else if (' \\ ' == p[ 0 ] ) {
285285 try {
286286 val decimalValue: Int = abs(p.substring(1 ).toInt())
287287 if (decimalValue <= groupIndex) {
288- parts[i] = " \\ " + capturedGroups.get( decimalValue)
288+ parts[i] = " \\ " + capturedGroups[ decimalValue]
289289 }
290290 } catch (ex: NumberFormatException ) {
291291 }
@@ -297,7 +297,7 @@ class CombinePrefixPattern {
297297 // Remove any prefix anchors so that the output will match anywhere.
298298 // ^^ really does mean an anchored match though.
299299 for (i in 0 until n) {
300- if ((" ^" == parts[i]) && " ^" != parts.get( i + 1 ) ) {
300+ if ((" ^" == parts[i]) && " ^" != parts[ i + 1 ] ) {
301301 parts[i] = " "
302302 }
303303 }
@@ -307,7 +307,7 @@ class CombinePrefixPattern {
307307 if (regex.options.contains(RegexOption .IGNORE_CASE ) && needToFoldCase) {
308308 for (i in 0 until n) {
309309 val p = parts[i]
310- val ch0: Char = if (p.length > 0 ) p[0 ] else ' 0'
310+ val ch0: Char = if (p.isNotEmpty() ) p[0 ] else ' 0'
311311 if (p.length >= 2 && ch0 == ' [' ) {
312312 parts[i] = caseFoldCharset(p)
313313 } else if (ch0 != ' \\ ' ) {
@@ -335,7 +335,7 @@ class CombinePrefixPattern {
335335 }
336336 var appendIndex = 0
337337 while (matchResult != null ) {
338- val cc = matchResult.groups.get( 0 ) ?.value?.get(0 )?.code
338+ val cc = matchResult.groups[ 0 ] ?.value?.get(0 )?.code
339339 mySb.append(p.substring(appendIndex,matchResult.range.first))
340340 appendIndex = matchResult.range.last
341341 if (cc != null ) {
0 commit comments