Skip to content

Commit 9346984

Browse files
author
Andrey Turbanov
committed
8347916: Simplify javax.swing.text.html.CSS.LengthUnit.getValue
Reviewed-by: azvegint, aivanov
1 parent 3c92392 commit 9346984

File tree

1 file changed

+6
-18
lines changed
  • src/java.desktop/share/classes/javax/swing/text/html

1 file changed

+6
-18
lines changed

src/java.desktop/share/classes/javax/swing/text/html/CSS.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,27 +3088,15 @@ else if (value.equals("smaller")) {
30883088
}
30893089

30903090
float getValue(boolean w3cLengthUnits) {
3091-
Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
3092-
float scale = 1;
3093-
if (units != null) {
3094-
Float scaleFloat = mapping.get(units);
3095-
if (scaleFloat != null) {
3096-
scale = scaleFloat.floatValue();
3097-
}
3098-
}
3099-
return this.value * scale;
3100-
3091+
return getValue(value, units, w3cLengthUnits);
31013092
}
31023093

3103-
static float getValue(float value, String units, Boolean w3cLengthUnits) {
3104-
Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
3105-
float scale = 1;
3106-
if (units != null) {
3107-
Float scaleFloat = mapping.get(units);
3108-
if (scaleFloat != null) {
3109-
scale = scaleFloat.floatValue();
3110-
}
3094+
static float getValue(float value, String units, boolean w3cLengthUnits) {
3095+
if (units == null) {
3096+
return value;
31113097
}
3098+
Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
3099+
float scale = mapping.getOrDefault(units, 1f);
31123100
return value * scale;
31133101
}
31143102

0 commit comments

Comments
 (0)