Hi Alan,

Just one nit.

On 03/16/2016 09:30 AM, Alan Bateman wrote:

I've refreshed the webrevs here:
http://cr.openjdk.java.net/~alanb/8142968/3


In java.lang.ClassLoader:

...the package-private definePackage(String name, Module m) is OK to use a single packages.compute(...) call performance-wise since it is pre-screened with packages.get() in public getDefinedPackage(String name) method. But there's also a package-private packages() method (a basis for public methods getPackages() and getDefinedPackages()) that constructs a Stream<Package> of defined Packages which unnecessarily calls definePackage() for each value of packages map:

    Stream<Package> packages() {
        return packages.values().stream()
.map(p -> definePackage(p.packageName(), p.module()));
    }


It would be nice performance-wise to avoid calling definePackage if the value is already a Package:

    Stream<Package> packages() {
        return packages.values().stream()
                       .map(p -> p instanceof Package
                                 ? (Package) p
: definePackage(p.packageName(), p.module()));
    }


Regards, Peter

Reply via email to