This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 1f380e3a40 Refactor to avoid use of Hashtable. No functional change.
1f380e3a40 is described below
commit 1f380e3a40395f911e0f52d33643b3693f5753c4
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Sep 15 16:54:30 2022 +0100
Refactor to avoid use of Hashtable. No functional change.
---
java/org/apache/jasper/compiler/Generator.java | 29 +++++++++-------------
.../apache/jasper/compiler/TagLibraryInfoImpl.java | 4 +--
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/java/org/apache/jasper/compiler/Generator.java
b/java/org/apache/jasper/compiler/Generator.java
index 45ff4a03d8..b0c83469ed 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -29,10 +29,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -911,9 +909,9 @@ class Generator {
* handlers: <key>: tag short name <value>: introspection info of tag
* handler for <prefix:shortName> tag
*/
- private final Hashtable<String,Hashtable<String,TagHandlerInfo>>
handlerInfos;
+ private final Map<String,Map<String,TagHandlerInfo>> handlerInfos;
- private final Hashtable<String,Integer> tagVarNumbers;
+ private final Map<String,Integer> tagVarNumbers;
private String parent;
@@ -951,8 +949,8 @@ class Generator {
this.methodsBuffered = methodsBuffered;
this.fragmentHelperClass = fragmentHelperClass;
methodNesting = 0;
- handlerInfos = new Hashtable<>();
- tagVarNumbers = new Hashtable<>();
+ handlerInfos = new HashMap<>();
+ tagVarNumbers = new HashMap<>();
textMap = new HashMap<>();
}
@@ -2026,7 +2024,7 @@ class Generator {
// Compute attribute value string for XML-style and named
// attributes
- Hashtable<String,String> map = new Hashtable<>();
+ Map<String,String> map = new HashMap<>();
// Validator ensures this is non-null
Node.JspAttribute[] attrs = n.getJspAttributes();
for (int i = 0; i < attrs.length; i++) {
@@ -2071,9 +2069,7 @@ class Generator {
out.print(" + " + elemName);
// Write remaining attributes
- Enumeration<String> enumeration = map.keys();
- while (enumeration.hasMoreElements()) {
- String attrName = enumeration.nextElement();
+ for (String attrName : map.keySet()) {
out.print(map.get(attrName));
}
@@ -2369,10 +2365,9 @@ class Generator {
private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n)
throws JasperException {
- Hashtable<String,TagHandlerInfo> handlerInfosByShortName =
- handlerInfos.get(n.getPrefix());
+ Map<String,TagHandlerInfo> handlerInfosByShortName =
handlerInfos.get(n.getPrefix());
if (handlerInfosByShortName == null) {
- handlerInfosByShortName = new Hashtable<>();
+ handlerInfosByShortName = new HashMap<>();
handlerInfos.put(n.getPrefix(), handlerInfosByShortName);
}
TagHandlerInfo handlerInfo =
@@ -4045,9 +4040,9 @@ class Generator {
*/
private static class TagHandlerInfo {
- private Hashtable<String, Method> methodMaps;
+ private Map<String, Method> methodMaps;
- private Hashtable<String, Class<?>> propertyEditorMaps;
+ private Map<String, Class<?>> propertyEditorMaps;
private Class<?> tagHandlerClass;
@@ -4065,8 +4060,8 @@ class Generator {
TagHandlerInfo(Node n, Class<?> tagHandlerClass,
ErrorDispatcher err) throws JasperException {
this.tagHandlerClass = tagHandlerClass;
- this.methodMaps = new Hashtable<>();
- this.propertyEditorMaps = new Hashtable<>();
+ this.methodMaps = new HashMap<>();
+ this.propertyEditorMaps = new HashMap<>();
try {
BeanInfo tagClassInfo =
Introspector.getBeanInfo(tagHandlerClass);
diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
index 949df622d8..10f44af3c9 100644
--- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
+++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
@@ -25,8 +25,8 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -349,7 +349,7 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements
TagConstants {
return null;
}
- Map<String, Object> initParams = new
Hashtable<>(validatorXml.getInitParams());
+ Map<String, Object> initParams = new
HashMap<>(validatorXml.getInitParams());
try {
Class<?> tlvClass =
ctxt.getClassLoader().loadClass(validatorClass);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]