commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1465504 - /commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java
Date Sun, 07 Apr 2013 23:01:23 GMT
Author: sebb
Date: Sun Apr  7 23:01:23 2013
New Revision: 1465504

URL: http://svn.apache.org/r1465504
Log:
Fetch char once from array

Modified:
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java?rev=1465504&r1=1465503&r2=1465504&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java Sun Apr
 7 23:01:23 2013
@@ -1376,19 +1376,20 @@ public class FilenameUtils {
         final ArrayList<String> list = new ArrayList<String>();
         final StringBuilder buffer = new StringBuilder();
         for (int i = 0; i < array.length; i++) {
-            if (array[i] == '?' || array[i] == '*') {
+            final char ch = array[i];
+            if (ch == '?' || ch == '*') {
                 if (buffer.length() != 0) {
                     list.add(buffer.toString());
                     buffer.setLength(0);
                 }
-                if (array[i] == '?') {
+                if (ch == '?') {
                     list.add("?");
-                } else if (list.isEmpty() ||
+                } else if (list.isEmpty() || // ch == '*' here; check if previous char was
'*'
                         i > 0 && list.get(list.size() - 1).equals("*") == false)
{
                     list.add("*");
                 }
             } else {
-                buffer.append(array[i]);
+                buffer.append(ch);
             }
         }
         if (buffer.length() != 0) {



Mime
View raw message