You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each modified node is transformed twice: once at the span, and again at the if/else. So, for <a><b><c><d/></c></b></a>, with c being modified, node a gets transformed twice, node b gets transformed four times (twice for each time a is transformed), and node c gets transformed eight times.
The text was updated successfully, but these errors were encountered:
@dcsobral said:
I propose the following rewrite of that method as a fix:
deftransform(ns: Seq[Node]):Seq[Node] = {
valxs= ns.toStream map transform
val (xs1, xs2) = xs zip ns span { case (x, n) => unchanged(n, x) }
if (xs2.isEmpty) ns
else (xs1 map (_._2)) ++ xs2.head._1 ++ transform(ns drop (xs1.length +1))
}
I considered modifying unchanged, but, as a protected method, it is part of the API. Also, ns take xs1.length might be better than xs1 map (_._2). This whole method could probably be made more efficient with a carefully constructed while loop, I think, but this, at least, solves the complexity problem.
It seems
BasicTransformer
has exponential complexity on the nesting level of the XML being processed. This is due to this method:Each modified node is transformed twice: once at the span, and again at the if/else. So, for
<a><b><c><d/></c></b></a>
, with c being modified, node a gets transformed twice, node b gets transformed four times (twice for each time a is transformed), and node c gets transformed eight times.The text was updated successfully, but these errors were encountered: