Optimisation from Ortwin Glueck (#SANDBOX-166) in which empty String arrays are replaced with constants.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/sandbox/csv/trunk@430240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2006-08-10 04:49:05 +00:00
parent d7dc07fc7c
commit 0558a35d91
1 changed files with 5 additions and 2 deletions

View File

@ -24,6 +24,9 @@ import java.io.IOException;
*/
public class CSVUtils {
private static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final String[][] EMPTY_DOUBLE_STRING_ARRAY = new String[0][0];
/**
* <p><code>CSVUtils</code> instances should NOT be constructed in
* standard programming.
@ -86,7 +89,7 @@ public class CSVUtils {
if (result == null) {
// since CSVStrategy ignores empty lines an empty array is returned
// (i.e. not "result = new String[][] {{""}};")
result = new String[0][0];
result = EMPTY_DOUBLE_STRING_ARRAY;
}
return result;
}
@ -108,7 +111,7 @@ public class CSVUtils {
}
// uh,jh: make sure that parseLine("").length == 0
if (s.length() == 0) {
return new String[0];
return EMPTY_STRING_ARRAY;
}
return (new CSVParser(new StringReader(s))).getLine();
}