You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2019/05/08 19:26:34 UTC

[tomcat] branch master updated: Replace uses of Vector with ArrayList.

This is an automated email from the ASF dual-hosted git repository.

schultz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new a5d2c73  Replace uses of Vector with ArrayList.
a5d2c73 is described below

commit a5d2c73544191763f3a20aaaaa12e810d1b0caee
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Wed May 8 21:26:11 2019 +0200

    Replace uses of Vector with ArrayList.
---
 java/org/apache/jasper/compiler/JspUtil.java | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JspUtil.java b/java/org/apache/jasper/compiler/JspUtil.java
index d5dc2c7..3a65eff 100644
--- a/java/org/apache/jasper/compiler/JspUtil.java
+++ b/java/org/apache/jasper/compiler/JspUtil.java
@@ -22,13 +22,15 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
-import java.util.Vector;
+
+import java.util.ArrayList;
 
 import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.JspCompilationContext;
 import org.apache.tomcat.Jar;
 import org.apache.tomcat.util.security.Escape;
+
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 
@@ -129,12 +131,12 @@ public class JspUtil {
 
         // AttributesImpl.removeAttribute is broken, so we do this...
         int tempLength = (attrs == null) ? 0 : attrs.getLength();
-        Vector<String> temp = new Vector<>(tempLength, 1);
+        ArrayList<String> temp = new ArrayList<>(tempLength);
         for (int i = 0; i < tempLength; i++) {
             @SuppressWarnings("null")  // If attrs==null, tempLength == 0
             String qName = attrs.getQName(i);
             if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) {
-                temp.addElement(qName);
+                temp.add(qName);
             }
         }
 
@@ -146,7 +148,7 @@ public class JspUtil {
                 Node node = tagBody.getNode(i);
                 if (node instanceof Node.NamedAttribute) {
                     String attrName = node.getAttributeValue("name");
-                    temp.addElement(attrName);
+                    temp.add(attrName);
                     // Check if this value appear in the attribute of the node
                     if (n.getAttributeValue(attrName) != null) {
                         err.jspError(n,
@@ -196,11 +198,8 @@ public class JspUtil {
         }
 
         // Now check to see if the rest of the attributes are valid too.
-        String attribute = null;
-
-        for (int j = 0; j < attrLeftLength; j++) {
+        for(String attribute : temp) {
             valid = false;
-            attribute = temp.elementAt(j);
             for (int i = 0; i < validAttributes.length; i++) {
                 if (attribute.equals(validAttributes[i].name)) {
                     valid = true;
@@ -763,7 +762,7 @@ public class JspUtil {
      * @return the components of the path
      */
     private static final String[] split(String path, String pat) {
-        Vector<String> comps = new Vector<>();
+        ArrayList<String> comps = new ArrayList<>();
         int pos = path.indexOf(pat);
         int start = 0;
         while (pos >= 0) {
@@ -777,11 +776,7 @@ public class JspUtil {
         if (start < path.length()) {
             comps.add(path.substring(start));
         }
-        String[] result = new String[comps.size()];
-        for (int i = 0; i < comps.size(); i++) {
-            result[i] = comps.elementAt(i);
-        }
-        return result;
+        return comps.toArray(new String[comps.size()]);
     }
 
     /**


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org