commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1557355 - /commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
Date Sat, 11 Jan 2014 11:55:51 GMT
Author: sebb
Date: Sat Jan 11 11:55:51 2014
New Revision: 1557355

URL: http://svn.apache.org/r1557355
Log:
No point using Vector for a local variable

Modified:
    commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java

Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java?rev=1557355&r1=1557354&r2=1557355&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java Sat Jan
11 11:55:51 2014
@@ -19,6 +19,7 @@
 package org.apache.commons.exec;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -345,7 +346,7 @@ public class CommandLine {
         final int inDoubleQuote = 2;
         int state = normal;
         final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
-        final Vector v = new Vector();
+        final ArrayList<String> list = new ArrayList<String>();
         StringBuffer current = new StringBuffer();
         boolean lastTokenHasBeenQuoted = false;
 
@@ -375,7 +376,7 @@ public class CommandLine {
                     state = inDoubleQuote;
                 } else if (" ".equals(nextTok)) {
                     if (lastTokenHasBeenQuoted || current.length() != 0) {
-                        v.addElement(current.toString());
+                        list.add(current.toString());
                         current = new StringBuffer();
                     }
                 } else {
@@ -387,7 +388,7 @@ public class CommandLine {
         }
 
         if (lastTokenHasBeenQuoted || current.length() != 0) {
-            v.addElement(current.toString());
+            list.add(current.toString());
         }
 
         if (state == inQuote || state == inDoubleQuote) {
@@ -395,9 +396,8 @@ public class CommandLine {
                     + toProcess);
         }
 
-        final String[] args = new String[v.size()];
-        v.copyInto(args);
-        return args;
+        final String[] args = new String[list.size()];
+        return list.toArray(args);
     }
 
     /**



Mime
View raw message