regex: Refactor predefined character classes.

This commit is contained in:
Ilya Matveev
2017-06-16 16:19:11 +07:00
committed by ilmat192
parent 9c81f9b402
commit bfcc0fc0d0
3 changed files with 304 additions and 356 deletions
@@ -9,21 +9,15 @@ fun codePointToString(codePoint: Int): String {
return fromCharArray(charArray, 0, charArray.size)
}
fun box() {}
// TODO: Here is a performance problem: an execution of this test requires much more time than it in Kotlin/JVM.
fun box1() {
fun box() {
// Regression for HARMONY-3145
var p = Regex("(\\p{all})+")
var res = true
var cnt = 0
var s: String
for (i in 0..1114111) {
if (i % 200000 == 0) {
println(i)
}
s = codePointToString(i)
// if (!s.matches(p.toString().toRegex())) { TODO: Uncomment when caching is done.
if (!s.matches(p)) {
cnt++
res = false
@@ -37,11 +31,7 @@ fun box1() {
cnt = 0
for (i in 0..1114111) {
if (i % 200000 == 0) {
println(i)
}
s = codePointToString(i)
// if (!s.matches(p.toString().toRegex())) { TODO: Uncomment when caching is done.
if (!s.matches(p)) {
cnt++
res = false