On Fri, 24 Apr 2026 02:23:24 GMT, Stuart Marks <[email protected]> wrote:
>> Thx for the examples, I detect an emphasis on code density that I'll apply
>> to future contributions. Map.of() isn't my favorite, for various reasons,
>> but it makes perfect sense here. Appreciate the explanations on these, too!
>
> OK, thanks. I guess though, I'd like not to over-emphasize code density.
> Certainly not to the point of "code golfing" to minimize the number of
> characters or anything like that. In the HashMap.java code the density of
> code is driven by reduction of the effective scope of a local variable and to
> avoid unnecessary field loads into local variables (as is the prevailing
> style in that file, from Doug Lea and Martin Buchholz). In the benchmark, if
> there's duplicate code, then yeah it ought to be removed. But there are other
> times I'll favor clarity over brevity.
Oh wait, I meant that you should only replace the stuff in the latter half of
the try-block that tests `putAll()`, but leave the stuff that tests `put()`.
Sorry if this wasn't clear. To be specific, please restore this part:
try {
check(m.put(3333, 77777) == null);
check(m.put(9134, 74982) == null);
check(m.get(9134) == 74982);
check(m.put(9134, 1382) == 74982);
check(m.get(9134) == 1382);
check(m.size() == 2);
checkFunctionalInvariants(m);
checkNPEConsistency(m);
and then continue with the stuff that tests `putAll()` with the line
int oldSize = m.size();
and also _not_ clearing the map beforehand.
Thanks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28243#discussion_r3135128481