You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/18 21:04:09 UTC
[commons-csv] 02/02: Remove unnecessary array creation for varargs.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
commit 5e9216d331d0c8c49d505370f90e3d29722df577
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 18 16:04:03 2019 -0500
Remove unnecessary array creation for varargs.
---
src/test/java/org/apache/commons/csv/CSVParserTest.java | 4 ++--
src/test/java/org/apache/commons/csv/PerformanceTest.java | 5 ++---
.../java/org/apache/commons/csv/issues/JiraCsv203Test.java | 14 +++++++-------
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java
index 310574a..0d8dd31 100644
--- a/src/test/java/org/apache/commons/csv/CSVParserTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java
@@ -296,12 +296,12 @@ public class CSVParserTest {
assertThrows(
IllegalArgumentException.class,
() -> CSVParser.parse("a,b,a\n1,2,3\nx,y,z",
- CSVFormat.DEFAULT.withHeader(new String[] {}).withAllowDuplicateHeaderNames(false)));
+ CSVFormat.DEFAULT.withHeader().withAllowDuplicateHeaderNames(false)));
}
@Test
public void testDuplicateHeadersAllowedByDefault() throws Exception {
- CSVParser.parse("a,b,a\n1,2,3\nx,y,z", CSVFormat.DEFAULT.withHeader(new String[] {}));
+ CSVParser.parse("a,b,a\n1,2,3\nx,y,z", CSVFormat.DEFAULT.withHeader());
}
@Test
diff --git a/src/test/java/org/apache/commons/csv/PerformanceTest.java b/src/test/java/org/apache/commons/csv/PerformanceTest.java
index 0f1bb2c..1f7884f 100644
--- a/src/test/java/org/apache/commons/csv/PerformanceTest.java
+++ b/src/test/java/org/apache/commons/csv/PerformanceTest.java
@@ -264,7 +264,7 @@ public class PerformanceTest {
private static Constructor<Lexer> getLexerCtor(final String clazz) throws Exception {
@SuppressWarnings("unchecked")
final Class<Lexer> lexer = (Class<Lexer>) Class.forName("org.apache.commons.csv." + clazz);
- return lexer.getConstructor(new Class<?>[]{CSVFormat.class, ExtendedBufferedReader.class});
+ return lexer.getConstructor(CSVFormat.class, ExtendedBufferedReader.class);
}
private static void testCSVLexer(final boolean newToken, final String test) throws Exception {
@@ -317,8 +317,7 @@ public class PerformanceTest {
private static Lexer createTestCSVLexer(final String test, final ExtendedBufferedReader input)
throws InstantiationException, IllegalAccessException, InvocationTargetException, Exception {
- return test.startsWith("CSVLexer") ? getLexerCtor(test)
- .newInstance(new Object[] { format, input }) : new Lexer(format, input);
+ return test.startsWith("CSVLexer") ? getLexerCtor(test).newInstance(format, input) : new Lexer(format, input);
}
private static Stats iterate(final Iterable<CSVRecord> it) {
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv203Test.java b/src/test/java/org/apache/commons/csv/issues/JiraCsv203Test.java
index bb11625..9c887bd 100644
--- a/src/test/java/org/apache/commons/csv/issues/JiraCsv203Test.java
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv203Test.java
@@ -37,7 +37,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals("\"N/A\",\"Hello\",\"N/A\",\"World\"\r\n", buffer.toString());
}
@@ -51,7 +51,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals("N/A,\"Hello\",N/A,\"World\"\r\n", buffer.toString());
}
@@ -64,7 +64,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals("N/A,Hello,N/A,World\r\n", buffer.toString());
}
@@ -78,7 +78,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals("N/A,Hello,N/A,World\r\n", buffer.toString());
}
@@ -92,7 +92,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals("N/A,\"Hello\",N/A,\"World\"\r\n", buffer.toString());
}
@@ -106,7 +106,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { null, "Hello", null, "World" });
+ printer.printRecord(null, "Hello", null, "World");
}
assertEquals(",\"Hello\",,\"World\"\r\n", buffer.toString());
}
@@ -120,7 +120,7 @@ public class JiraCsv203Test {
final StringBuffer buffer = new StringBuffer();
try (final CSVPrinter printer = new CSVPrinter(buffer, format)) {
- printer.printRecord(new Object[] { "", "Hello", "", "World" });
+ printer.printRecord("", "Hello", "", "World");
//printer.printRecord(new Object[] { null, "Hello", null, "World" });
}
assertEquals("\"\",\"Hello\",\"\",\"World\"\r\n", buffer.toString());