Skip to content

Commit 24de9de

Browse files
author
Andrey Turbanov
committedJan 16, 2025
8347370: Unnecessary Hashtable usage in javax.swing.text.html.HTML
Reviewed-by: aivanov, azvegint
1 parent d23ad01 commit 24de9de

File tree

1 file changed

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

1 file changed

+12
-10
lines changed
 

‎src/java.desktop/share/classes/javax/swing/text/html/HTML.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021, 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
@@ -30,6 +30,7 @@
3030
import java.io.Serial;
3131
import java.io.Serializable;
3232
import java.util.Hashtable;
33+
import java.util.Map;
3334

3435
import javax.swing.text.AttributeSet;
3536
import javax.swing.text.StyleConstants;
@@ -1169,7 +1170,16 @@ public String toString() {
11691170
private static final Hashtable<String, Tag> tagHashtable = new Hashtable<String, Tag>(73);
11701171

11711172
/** Maps from StyleConstant key to HTML.Tag. */
1172-
private static final Hashtable<Object, Tag> scMapping = new Hashtable<Object, Tag>(8);
1173+
private static final Map<Object, Tag> scMapping = Map.of(
1174+
StyleConstants.Bold, Tag.B,
1175+
StyleConstants.Italic, Tag.I,
1176+
StyleConstants.Underline, Tag.U,
1177+
StyleConstants.StrikeThrough, Tag.STRIKE,
1178+
StyleConstants.Superscript, Tag.SUP,
1179+
StyleConstants.Subscript, Tag.SUB,
1180+
StyleConstants.FontFamily, Tag.FONT,
1181+
StyleConstants.FontSize, Tag.FONT
1182+
);
11731183

11741184
static {
11751185

@@ -1185,14 +1195,6 @@ public String toString() {
11851195
allAttributes[i]);
11861196
}
11871197
StyleContext.registerStaticAttributeKey(HTML.NULL_ATTRIBUTE_VALUE);
1188-
scMapping.put(StyleConstants.Bold, Tag.B);
1189-
scMapping.put(StyleConstants.Italic, Tag.I);
1190-
scMapping.put(StyleConstants.Underline, Tag.U);
1191-
scMapping.put(StyleConstants.StrikeThrough, Tag.STRIKE);
1192-
scMapping.put(StyleConstants.Superscript, Tag.SUP);
1193-
scMapping.put(StyleConstants.Subscript, Tag.SUB);
1194-
scMapping.put(StyleConstants.FontFamily, Tag.FONT);
1195-
scMapping.put(StyleConstants.FontSize, Tag.FONT);
11961198
}
11971199

11981200
/**

0 commit comments

Comments
 (0)
Please sign in to comment.