Commit 3f25eace authored by Mygod's avatar Mygod

Use kotlin's CharSequence.split

This partially reverts 1010edc5.
At that time, Kotlin (1.2.10) has a slow implementation of split. This has since been addressed in https://github.com/JetBrains/kotlin/commit/2805371bdcfa05bd2e72f86077f3a54518fd89ae and released in 1.2.30. As far as I can see, this is a faster implementation than Android's Pattern/Splitter.fastSplit for this particular use case.
parent 63448896
......@@ -117,8 +117,7 @@ class Acl {
var subnets: SortedList<Subnet>? = if (defaultBypass) proxySubnets else bypassSubnets
reader.useLines {
for (line in it) {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
val blocks = (line as java.lang.String).split("#", 2)
val blocks = line.split('#', limit = 2)
val url = networkAclParser.matchEntire(blocks.getOrElse(1) { "" })?.groupValues?.getOrNull(1)
if (url != null) urls.add(URL(url))
when (val input = blocks[0].trim()) {
......
......@@ -27,8 +27,7 @@ import java.util.*
class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet> {
companion object {
fun fromString(value: String): Subnet? {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
val parts = (value as java.lang.String).split("/", 2)
val parts = value.split('/', limit = 2)
val addr = parts[0].parseNumericAddress() ?: return null
return if (parts.size == 2) try {
val prefixSize = parts[1].toInt()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment