mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-23 21:12:34 +01:00
Optimize formatter use
This commit is contained in:
@@ -52,17 +52,17 @@ class XmlResourceBundle internal constructor(internal val lookup: ConcurrentHash
|
||||
private fun String.replaceAndroid() = replace("\\n", "%n")
|
||||
|
||||
fun getStringA(key: String): String {
|
||||
return Formatter().format(getString(key).replaceAndroid())
|
||||
.let { formatter ->
|
||||
formatter.toString().also { formatter.close() }
|
||||
}
|
||||
return Formatter().use {
|
||||
it.format(getString(key).replaceAndroid())
|
||||
.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun getString(key: String, vararg replacements: Any?): String {
|
||||
return Formatter().format(getString(key).replaceAndroid(), *replacements)
|
||||
.let { formatter ->
|
||||
formatter.toString().also { formatter.close() }
|
||||
}
|
||||
return Formatter().use {
|
||||
it.format(getString(key).replaceAndroid(), *replacements)
|
||||
.toString()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -127,12 +127,10 @@ sealed class SourceSettingsView<T, R : Any?> {
|
||||
}
|
||||
}
|
||||
|
||||
fun withFormat(text: String, value: Any?): String {
|
||||
return Formatter().format(text, value)
|
||||
.let { formatter ->
|
||||
formatter.toString()
|
||||
.also { formatter.close() }
|
||||
}
|
||||
private fun withFormat(text: String, value: Any?): String {
|
||||
return Formatter().use {
|
||||
it.format(text, value).toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun SourceSettingsView(index: Int, preference: SourcePreference): SourceSettingsView<*, *> {
|
||||
|
||||
Reference in New Issue
Block a user