Skip to content
Snippets Groups Projects
Verified Commit a48008d5 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improve performance and clarity of hostmask splitter

parent bb25a14c
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -20,20 +20,15 @@ ...@@ -20,20 +20,15 @@
package de.kuschku.libquassel.util.irc package de.kuschku.libquassel.util.irc
object HostmaskHelper { object HostmaskHelper {
fun nick(mask: String): String { fun nick(mask: String) = mask
val (nick, _, _) = split(mask) .substringBefore('!', missingDelimiterValue = mask)
return nick
}
fun user(mask: String): String { fun user(mask: String) = mask
val (_, user, _) = split(mask) .substringBeforeLast('@', missingDelimiterValue = mask)
return user .substringAfter('!', missingDelimiterValue = "")
}
fun host(mask: String): String { fun host(mask: String) = mask
val (_, _, host) = split(mask) .substringAfterLast('@', missingDelimiterValue = "")
return host
}
fun split(mask: String): Triple<String, String, String> { fun split(mask: String): Triple<String, String, String> {
val userPartHostSplit = mask.split("@", limit = 2) val userPartHostSplit = mask.split("@", limit = 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment