Skip to content

Commit 2009a2c

Browse files
committed
Fetch char once from array
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1465504 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8d0d2d8 commit 2009a2c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/org/apache/commons/io/FilenameUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,19 +1376,20 @@ static String[] splitOnTokens(final String text) {
13761376
final ArrayList<String> list = new ArrayList<String>();
13771377
final StringBuilder buffer = new StringBuilder();
13781378
for (int i = 0; i < array.length; i++) {
1379-
if (array[i] == '?' || array[i] == '*') {
1379+
final char ch = array[i];
1380+
if (ch == '?' || ch == '*') {
13801381
if (buffer.length() != 0) {
13811382
list.add(buffer.toString());
13821383
buffer.setLength(0);
13831384
}
1384-
if (array[i] == '?') {
1385+
if (ch == '?') {
13851386
list.add("?");
1386-
} else if (list.isEmpty() ||
1387+
} else if (list.isEmpty() || // ch == '*' here; check if previous char was '*'
13871388
i > 0 && list.get(list.size() - 1).equals("*") == false) {
13881389
list.add("*");
13891390
}
13901391
} else {
1391-
buffer.append(array[i]);
1392+
buffer.append(ch);
13921393
}
13931394
}
13941395
if (buffer.length() != 0) {

0 commit comments

Comments
 (0)