Kotlin optimization form #1435

This commit is contained in:
Benoit Marty 2020-11-20 09:05:53 +01:00
parent eb7ee49096
commit 8fb3c68573

View File

@ -44,13 +44,12 @@ object PermalinkParser {
if (fragment.isNullOrEmpty()) { if (fragment.isNullOrEmpty()) {
return PermalinkData.FallbackLink(uri) return PermalinkData.FallbackLink(uri)
} }
val indexOfQuery = fragment.indexOf("?") val safeFragment = fragment.substringBefore('?')
val safeFragment = if (indexOfQuery != -1) fragment.substring(0, indexOfQuery) else fragment
val viaQueryParameters = fragment.getViaParameters() val viaQueryParameters = fragment.getViaParameters()
// we are limiting to 2 params // we are limiting to 2 params
val params = safeFragment val params = safeFragment
.split(MatrixPatterns.SEP_REGEX.toRegex()) .split(MatrixPatterns.SEP_REGEX)
.filter { it.isNotEmpty() } .filter { it.isNotEmpty() }
.take(2) .take(2)