On Wed, 15 Mar 2023 18:20:10 GMT, Chen Liang <[email protected]> wrote:

>> Pavel Rappo has updated the pull request incrementally with two additional 
>> commits since the last revision:
>> 
>>  - Trivially rephrase TODO
>>  - Address feedback
>>    
>>     - renames simplename to simpleName
>>     - links to the relevant JBS issue from TODOs
>
> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
>  line 888:
> 
>> 886:             for (Kind kind : Kind.values()) {
>> 887:                 orderedMembers.compute(kind, (k, v) -> v == null ? 
>> List.of() : Collections.unmodifiableList(v));
>> 888:                 namedMembers.compute(kind, (k, v) -> v == null ? 
>> Map.of() : Collections.unmodifiableMap(v));
> 
> Can just use `replaceAll` than using a for loop

There's a cost of changing that to this:

    // protect from unintended change
    orderedMembers.replaceAll((k, l) -> Collections.unmodifiableList(l));
    namedMembers.replaceAll((k, m) -> Collections.unmodifiableMap(m));

That cost is using default values for absent kinds:

    List<Element> getOrderedMembers(Kind kind) {
        return orderedMembers.getOrDefault(kind, List.of());
    }

    List<Element> getMembers(Name simpleName, Kind kind) {
        return namedMembers.getOrDefault(kind, Map.of())
            .getOrDefault(simpleName, List.of());
    }

Or did you mean something else?

-------------

PR: https://git.openjdk.org/jdk/pull/13044

Reply via email to