> From: Alan Bateman <alan.bate...@oracle.com> > To: Thomas Watson/Austin/IBM@IBMUS, jigsaw-dev@openjdk.java.net > Date: 03/09/2017 10:07 AM > Subject: Re: Controller ensureInLayer is slow when using addReads/ > addOpens for Layers with large numbers of modules > > There wasn't any text in your mail (don't know if this was intentional > or not). > > In any case, this is trivially improved, it just hasn't come up before, > probably because the Controller API is somewhat niche. > > -Alan >
Sorry, my mail system adds stuff that the mailing list doesn't like, let me try this again: The Controller ensureInLayer method has this. private void ensureInLayer(Module source) { if (!layer.modules().contains(source)) throw new IllegalArgumentException(source + " not in layer"); } The implementation of Layer.modules() is terribly expensive when trying to collect the complete set of modules only to perform a contains check. Can this be changed to something more simple like this: private void ensureInLayer(Module source) { if (!layer.equals(source.getLayer())) throw new IllegalArgumentException(source + " not in layer"); } It also seems like Layer.modules() should be optimized since the set of modules never changes for a Layer instance. But that method has to do a new set collection each call. Tom