Affects Version/s: None
Fix Version/s: 1.2.10-core
While looking at some test cases we noticed that EncoderUtils::_writeURL uses a lot of CPU to do its work. The basic problem is that frequent calls to charAt and calls to underlying writer to write just char or int can be very expensive.
The overall optimization idea is:
1. Instead of doing charAt do toCharArray once. This will use a little bit more of transient memory but it will be faster
2. Instead of doing frequent writes to the writer create one StringBuilder and work on it. Once _writeURL is done with all the transformations do the finale write(string) to the underlying writer
In our test case we had 4200 calls to _writeURL which used 2356ms of CPU time. With the optimizations the same number of calls uses 268ms. This is almost 9x improvement
Attached is the patch for the changes