Skip to content

BasicTransformer has exponential complexity #58

Closed
@biswanaths

Description

@biswanaths

Please see
https://issues.scala-lang.org/browse/SI-3689
https://issues.scala-lang.org/browse/SI-4528

It seems BasicTransformer has exponential complexity on the nesting level of the XML being processed. This is due to this method:

def transform(ns: Seq[Node]): Seq[Node] = {
  val (xs1, xs2) = ns span (n => unchanged(n, transform(n)))

  if (xs2.isEmpty) ns
  else xs1 ++ transform(xs2.head) ++ transform(xs2.tail)
}

Each modified node is transformed twice: once at the span, and again at the if/else. So, for , 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions