File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
lib/src/net/alphadev/opml Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,14 @@ import nl.adaptivity.xmlutil.serialization.XML
5
5
6
6
private const val INDENT_SIZE = 4
7
7
8
- fun formatOpmlFile ( opmlFile : OpmlFile ): String? = try {
8
+ private val xml by lazy {
9
9
XML {
10
10
indent = INDENT_SIZE
11
- }.encodeToString(OpmlFile .serializer(), opmlFile) + " \n "
11
+ }
12
+ }
13
+
14
+ fun formatOpmlFile (opmlFile : OpmlFile ): String? = try {
15
+ xml.encodeToString(OpmlFile .serializer(), opmlFile) + " \n "
12
16
} catch (_: Throwable ) {
13
17
null
14
18
}
Original file line number Diff line number Diff line change @@ -4,8 +4,12 @@ import kotlinx.serialization.decodeFromString
4
4
import net.alphadev.opml.format.OpmlFile
5
5
import nl.adaptivity.xmlutil.serialization.XML
6
6
7
+ private val xml by lazy {
8
+ XML ()
9
+ }
10
+
7
11
fun parseOpmlFile (input : String ): OpmlFile ? = try {
8
- XML () .decodeFromString<OpmlFile >(input)
12
+ xml .decodeFromString<OpmlFile >(input)
9
13
} catch (_: Throwable ) {
10
14
null
11
15
}
You can’t perform that action at this time.
0 commit comments