Bug 567595 - fix quadratic runtime of resolveRuntimeClasspath

JavaRuntime.resolveRuntimeClasspath first resolves the classpath and
then removes the entry for the JRE. The latter step has quadratic
runtime over the length of the classpath. It iterates over all entries.
For each entry it calls JavaProject.findPackageFragmentRoot(), which
calls JavaProject.getAllPackageFragmentRoots() and then iterates
over all package fragment roots.

Fixed by computing the path to the JRE before the outer loop. This
reduces the runtime to O(n).

Signed-off-by: Andreas Huber <ahe@lucares.de>
Change-Id: I3e37c1cfce26d82dbcaf814bc27c5722fee9e22a
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/180456
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Andrey Loskutov <loskutov@gmx.de>
1 file changed