Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasicTransformer has exponential complexity #58

Closed
biswanaths opened this issue Jun 30, 2015 · 2 comments
Closed

BasicTransformer has exponential complexity #58

biswanaths opened this issue Jun 30, 2015 · 2 comments

Comments

@biswanaths
Copy link
Contributor

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.

biswanaths added a commit that referenced this issue Jul 29, 2015
Fix #58 (SI-4528) BasicTransformer has no longer exponential complexity
@mlin6436
Copy link

mlin6436 commented Oct 5, 2015

Hi,

Is there any prospect this fix being released soon, cos my team is currently using the patch to get around the exponential complexity problem?

Thanks a lot.

@biswanaths
Copy link
Contributor Author

Hey, sorry that your team has to use patch for this issue. I will update when we can do a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants