Use Sequences on joinToString (#3400)
* Use more Sequences to reduce collection processing https://kotlinlang.org/docs/sequences.html * Use joinToString * Fix style * Revert "Use more Sequences to reduce collection processing" This reverts commit acf8071d9e62af1366b40dc6cb0ce43b4b355ec2. * Fix
This commit is contained in:
parent
f71aa55bbe
commit
f1d46766eb
|
@ -1,6 +1,5 @@
|
||||||
package com.keylesspalace.tusky.network
|
package com.keylesspalace.tusky.network
|
||||||
|
|
||||||
import android.text.TextUtils
|
|
||||||
import com.keylesspalace.tusky.entity.Filter
|
import com.keylesspalace.tusky.entity.Filter
|
||||||
import com.keylesspalace.tusky.entity.Status
|
import com.keylesspalace.tusky.entity.Status
|
||||||
import com.keylesspalace.tusky.util.parseAsMastodonHtml
|
import com.keylesspalace.tusky.util.parseAsMastodonHtml
|
||||||
|
@ -60,9 +59,11 @@ class FilterModel @Inject constructor() {
|
||||||
val nonExpiredFilters = filters.filter { it.expiresAt?.before(now) != true }
|
val nonExpiredFilters = filters.filter { it.expiresAt?.before(now) != true }
|
||||||
if (nonExpiredFilters.isEmpty()) return null
|
if (nonExpiredFilters.isEmpty()) return null
|
||||||
val tokens = nonExpiredFilters
|
val tokens = nonExpiredFilters
|
||||||
|
.asSequence()
|
||||||
.map { filterToRegexToken(it) }
|
.map { filterToRegexToken(it) }
|
||||||
|
.joinToString("|")
|
||||||
|
|
||||||
return Pattern.compile(TextUtils.join("|", tokens), Pattern.CASE_INSENSITIVE)
|
return Pattern.compile(tokens, Pattern.CASE_INSENSITIVE)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Reference in New Issue