[Bug]: Severe Performance Regression in toString
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
### Describe the bug
So apparently, the PrettyPrinter can now change the contents of an element. Ignoring if this is a good idea or not (seems pretty bad at first glance), this means that the toString method now clones itself before passing itself to the PrettyPrinter. This results in significantly reduced performance when turning an element back into code.
Perhaps a different, faster method for producing code or perhaps rethink allowing the PrettyPrinter to change an Element's contents.
Either way, please make the toString method faster and cause it not to use so much memory. Perhaps even make it not use String but instead take a StringBuilder so the strings don't get internalized and consume so much memory.
### Source code you are trying to analyze/transform
```Java
// The biggest Java file you can find
```
### Source code for your Spoon processing
```Java
Launcher l = new Launcher();
l.addInputResource(new FileSystemFile("ReallyBig.java"));
CtType tpe = l.buildModel().getAllTypes().get(0);
System.out.println("time to start the profiler");
Thread.sleep(15000);
tpe.toString();
```
### Actual output
```Java
N/A
```
### Expected output
```Java
N/A
```
### Spoon Version
11.2.1
### JVM Version
java 17
### What operating system are you using?
Ubuntu
Contributor guide
Assessment
This issue has not been assessed yet.