RFR: 8347916: Simplify javax.swing.text.html.CSS.LengthUnit.getValue

Alexey Ivanov aivanov at openjdk.org
Fri Jan 17 17:46:39 UTC 2025


On Fri, 1 Nov 2024 14:43:39 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> Static and non-static `CSS.LengthUnit.getValue` methods essentially do the same thing.
> https://github.com/openjdk/jdk/blob/751a914b0a377d4e1dd30d2501f0ab4e327dea34/src/java.desktop/share/classes/javax/swing/text/html/CSS.java#L3085-L3096
> 
> https://github.com/openjdk/jdk/blob/751a914b0a377d4e1dd30d2501f0ab4e327dea34/src/java.desktop/share/classes/javax/swing/text/html/CSS.java#L3098-L3108
> 
> 1. delegate one to another to reduce code duplication.
> 2. use primitive `boolean` type as parameter to avoid boxing
> 3. take advantage of `Map.getOrDefault()` to simplify code futher

Looks good.

I'm running tests.

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

Marked as reviewed by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/21833#pullrequestreview-2559614153


More information about the client-libs-dev mailing list