Skip to content

Commit c9c8f21

Browse files
committed
Use List[Node] in toString
1 parent 63e24f5 commit c9c8f21

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

shared/src/main/scala/scala/xml/Utility.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,16 @@ object Utility extends AnyRef with parsing.TokenTests {
219219
minimizeTags: MinimizeMode.Value,
220220
sb: StringBuilder
221221
): Unit = {
222-
@tailrec def ser(nss: List[Seq[Node]], pscopes: List[NamespaceBinding], spaced: List[Boolean], toClose: List[Node]): Unit = nss match {
223-
case List(ns) if ns.isEmpty =>
224-
case ns :: rests if ns.isEmpty =>
222+
@tailrec def ser(nss: List[List[Node]], pscopes: List[NamespaceBinding], spaced: List[Boolean], toClose: List[Node]): Unit = nss match {
223+
case List(Nil) =>
224+
case Nil :: rests =>
225225
if (toClose.head != null) {
226226
sb.append("</")
227227
toClose.head.nameToString(sb)
228228
sb.append('>')
229229
}
230230
ser(rests, pscopes.tail, spaced.tail, toClose.tail)
231-
case ns1 :: r =>
232-
val (n, ns) = (ns1.head, ns1.tail)
231+
case (n :: ns) :: r =>
233232
def sp(): Unit = if (ns.nonEmpty && spaced.head) sb.append(' ')
234233
n match {
235234
case c: Comment =>
@@ -243,7 +242,7 @@ object Utility extends AnyRef with parsing.TokenTests {
243242
sp()
244243
ser(ns :: r, pscopes, spaced, toClose)
245244
case g: Group =>
246-
ser(g.nodes :: ns :: r, g.scope :: pscopes, false :: spaced, null :: toClose)
245+
ser(g.nodes.toList :: ns :: r, g.scope :: pscopes, false :: spaced, null :: toClose)
247246
case e: Elem =>
248247
sb.append('<')
249248
e.nameToString(sb)
@@ -259,12 +258,12 @@ object Utility extends AnyRef with parsing.TokenTests {
259258
} else {
260259
sb.append('>')
261260
val csp = e.child.forall(isAtomAndNotText)
262-
ser(e.child :: ns :: r, e.scope :: pscopes, csp :: spaced, e :: toClose)
261+
ser(e.child.toList :: ns :: r, e.scope :: pscopes, csp :: spaced, e :: toClose)
263262
}
264263
case n => throw new IllegalArgumentException("Don't know how to serialize a " + n.getClass.getName)
265264
}
266265
}
267-
ser(List(ns), List(pscope), List(spaced), Nil)
266+
ser(List(ns.toList), List(pscope), List(spaced), Nil)
268267
}
269268

270269
def sequenceToXML(

0 commit comments

Comments
 (0)