Skip to content

Commit 56a1877

Browse files
author
Andrey Turbanov
committed
8348170: Unnecessary Hashtable usage in CSS.styleConstantToCssMap
Reviewed-by: azvegint, aivanov
1 parent 9768f60 commit 56a1877

File tree

1 file changed

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

1 file changed

+36
-34
lines changed

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

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1097,7 +1097,7 @@ private static int getTableBorder(AttributeSet tableAttr) {
10971097
* up a translation from StyleConstants (i.e. the <em>well known</em>
10981098
* attributes) to the associated CSS attributes.
10991099
*/
1100-
private static final Hashtable<Object, Attribute> styleConstantToCssMap = new Hashtable<Object, Attribute>(17);
1100+
private static final Map<Object, Attribute> styleConstantToCssMap;
11011101
/** Maps from HTML value to a CSS value. Used in internal mapping. */
11021102
private static final Hashtable<String, CSS.Value> htmlValueToCssValueMap = new Hashtable<String, CSS.Value>(8);
11031103
/** Maps from CSS value (string) to internal value. */
@@ -1167,38 +1167,40 @@ private static int getTableBorder(AttributeSet tableAttr) {
11671167
);
11681168

11691169
// initialize StyleConstants mapping
1170-
styleConstantToCssMap.put(StyleConstants.FontFamily,
1171-
CSS.Attribute.FONT_FAMILY);
1172-
styleConstantToCssMap.put(StyleConstants.FontSize,
1173-
CSS.Attribute.FONT_SIZE);
1174-
styleConstantToCssMap.put(StyleConstants.Bold,
1175-
CSS.Attribute.FONT_WEIGHT);
1176-
styleConstantToCssMap.put(StyleConstants.Italic,
1177-
CSS.Attribute.FONT_STYLE);
1178-
styleConstantToCssMap.put(StyleConstants.Underline,
1179-
CSS.Attribute.TEXT_DECORATION);
1180-
styleConstantToCssMap.put(StyleConstants.StrikeThrough,
1181-
CSS.Attribute.TEXT_DECORATION);
1182-
styleConstantToCssMap.put(StyleConstants.Superscript,
1183-
CSS.Attribute.VERTICAL_ALIGN);
1184-
styleConstantToCssMap.put(StyleConstants.Subscript,
1185-
CSS.Attribute.VERTICAL_ALIGN);
1186-
styleConstantToCssMap.put(StyleConstants.Foreground,
1187-
CSS.Attribute.COLOR);
1188-
styleConstantToCssMap.put(StyleConstants.Background,
1189-
CSS.Attribute.BACKGROUND_COLOR);
1190-
styleConstantToCssMap.put(StyleConstants.FirstLineIndent,
1191-
CSS.Attribute.TEXT_INDENT);
1192-
styleConstantToCssMap.put(StyleConstants.LeftIndent,
1193-
CSS.Attribute.MARGIN_LEFT);
1194-
styleConstantToCssMap.put(StyleConstants.RightIndent,
1195-
CSS.Attribute.MARGIN_RIGHT);
1196-
styleConstantToCssMap.put(StyleConstants.SpaceAbove,
1197-
CSS.Attribute.MARGIN_TOP);
1198-
styleConstantToCssMap.put(StyleConstants.SpaceBelow,
1199-
CSS.Attribute.MARGIN_BOTTOM);
1200-
styleConstantToCssMap.put(StyleConstants.Alignment,
1201-
CSS.Attribute.TEXT_ALIGN);
1170+
styleConstantToCssMap = Map.ofEntries(
1171+
Map.entry(StyleConstants.FontFamily,
1172+
CSS.Attribute.FONT_FAMILY),
1173+
Map.entry(StyleConstants.FontSize,
1174+
CSS.Attribute.FONT_SIZE),
1175+
Map.entry(StyleConstants.Bold,
1176+
CSS.Attribute.FONT_WEIGHT),
1177+
Map.entry(StyleConstants.Italic,
1178+
CSS.Attribute.FONT_STYLE),
1179+
Map.entry(StyleConstants.Underline,
1180+
CSS.Attribute.TEXT_DECORATION),
1181+
Map.entry(StyleConstants.StrikeThrough,
1182+
CSS.Attribute.TEXT_DECORATION),
1183+
Map.entry(StyleConstants.Superscript,
1184+
CSS.Attribute.VERTICAL_ALIGN),
1185+
Map.entry(StyleConstants.Subscript,
1186+
CSS.Attribute.VERTICAL_ALIGN),
1187+
Map.entry(StyleConstants.Foreground,
1188+
CSS.Attribute.COLOR),
1189+
Map.entry(StyleConstants.Background,
1190+
CSS.Attribute.BACKGROUND_COLOR),
1191+
Map.entry(StyleConstants.FirstLineIndent,
1192+
CSS.Attribute.TEXT_INDENT),
1193+
Map.entry(StyleConstants.LeftIndent,
1194+
CSS.Attribute.MARGIN_LEFT),
1195+
Map.entry(StyleConstants.RightIndent,
1196+
CSS.Attribute.MARGIN_RIGHT),
1197+
Map.entry(StyleConstants.SpaceAbove,
1198+
CSS.Attribute.MARGIN_TOP),
1199+
Map.entry(StyleConstants.SpaceBelow,
1200+
CSS.Attribute.MARGIN_BOTTOM),
1201+
Map.entry(StyleConstants.Alignment,
1202+
CSS.Attribute.TEXT_ALIGN)
1203+
);
12021204

12031205
// HTML->CSS
12041206
htmlValueToCssValueMap.put("disc", CSS.Value.DISC);

0 commit comments

Comments
 (0)