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

Andrey Turbanov aturbanov at openjdk.org
Thu Jan 16 12:13:12 UTC 2025


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

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

Commit messages:
 - [PATCH] Simplify javax.swing.text.html.CSS.LengthUnit.getValue

Changes: https://git.openjdk.org/jdk/pull/21833/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21833&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347916
  Stats: 20 lines in 1 file changed: 2 ins; 14 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/21833.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21833/head:pull/21833

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


More information about the client-libs-dev mailing list