Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder [v2]

2023-05-22 Thread Andrey Turbanov
On Tue, 4 Apr 2023 20:50:00 GMT, Andrey Turbanov wrote: >> `Map.containsKey` call is sometimes unnecessary, when it's known that `Map` >> doesn't contain `null` values. >> Instead of pair containsKey+put we can use putIfAbsent and compare result >> with null. >> Result code is shorter and a bit

Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder

2023-04-06 Thread Alan Bateman
On Tue, 4 Apr 2023 20:43:13 GMT, Andrey Turbanov wrote: > But now `requireServiceTypeName` is called unconditionally. requireServiceTypeName(service) should only be called when using the API. The non-strict route is when parsing a module-info on the module path, the checks that the names are l

Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder

2023-04-04 Thread Andrey Turbanov
On Tue, 4 Apr 2023 13:57:26 GMT, Alan Bateman wrote: > If you are changing uses(String) then it should obey `strict`, meaning put > this at the beginning of the method > > ``` > if (strict) { > requireServiceTypeName(service); > } > ``` But now `requireServiceTypeName` is called unconditio

Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder [v2]

2023-04-04 Thread Andrey Turbanov
> `Map.containsKey` call is sometimes unnecessary, when it's known that `Map` > doesn't contain `null` values. > Instead of pair containsKey+put we can use putIfAbsent and compare result > with null. > Result code is shorter and a bit faster. Andrey Turbanov has updated the pull request incremen

Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder

2023-04-04 Thread Alan Bateman
On Tue, 4 Apr 2023 12:37:15 GMT, Andrey Turbanov wrote: > Seems we can update `java.lang.module.ModuleDescriptor.Builder#uses` too to > directly call `add` instead of `contains`+`add` If you are changing uses(String) then it should obey `strict`, meaning put this at the beginning of the method

Re: RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder

2023-04-04 Thread Andrey Turbanov
On Mon, 3 Apr 2023 08:08:45 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that `Map` > doesn't contain `null` values. > Instead of pair containsKey+put we can use putIfAbsent and compare result > with null. > Result code is shorter and a bit fast

RFR: 8305538: Avoid redundant HashMap.containsKey call in ModuleDescriptor.Builder

2023-04-04 Thread Andrey Turbanov
`Map.containsKey` call is sometimes unnecessary, when it's known that `Map` doesn't contain `null` values. Instead of pair containsKey+put we can use putIfAbsent and compare result with null. Result code is shorter and a bit faster. - Commit messages: - [PATCH] Avoid redundant Hash