StdLib deprecations cleanup: string operations.

This commit is contained in:
Ilya Gorbunov
2015-06-25 22:28:29 +03:00
parent 86f4a1b6e4
commit 35166f44ae
7 changed files with 20 additions and 19 deletions
@@ -695,6 +695,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
}
val pattern = "[\\.\\_\\-]".toRegex()
val digitsPattern = "\\d+".toRegex()
val part1 = v1.split(pattern)
val part2 = v2.split(pattern)
@@ -704,7 +705,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
val p2 = part2[idx]
val cmp: Int
if (p1.matches("\\d+") && p2.matches("\\d+")) {
if (p1.matches(digitsPattern) && p2.matches(digitsPattern)) {
cmp = p1.toInt().compareTo(p2.toInt())
} else {
cmp = part1[idx].compareTo(part2[idx])
@@ -722,7 +723,7 @@ private fun compareVersionNumbers(v1: String?, v2: String?): Int {
while (idx < parts.size()) {
val p = parts[idx]
val cmp: Int
if (p.matches("\\d+")) {
if (p.matches(digitsPattern)) {
cmp = Integer(p).compareTo(0)
} else {
cmp = 1