Skip to content

Commit 723a5c9

Browse files
committed
Convert cascading if-else to switch
1 parent af49daa commit 723a5c9

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

src/test/java/org/apache/commons/csv/PerformanceTest.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,42 @@ public static void main(final String [] args) throws Exception {
143143
System.out.printf("Max count: %d%n%n", max);
144144

145145
for (final String test : tests) {
146-
if ("file".equals(test)) {
146+
switch (test) {
147+
case "file":
147148
testReadBigFile(false);
148-
} else if ("split".equals(test)) {
149+
break;
150+
case "split":
149151
testReadBigFile(true);
150-
} else if ("csv".equals(test)) {
152+
break;
153+
case "csv":
151154
testParseCommonsCSV();
152-
} else if ("csv-path".equals(test)) {
155+
break;
156+
case "csv-path":
153157
testParsePath();
154-
} else if ("csv-path-db".equals(test)) {
158+
break;
159+
case "csv-path-db":
155160
testParsePathDoubleBuffering();
156-
} else if ("csv-url".equals(test)) {
161+
break;
162+
case "csv-url":
157163
testParseURL();
158-
} else if ("lexreset".equals(test)) {
164+
break;
165+
case "lexreset":
159166
testCSVLexer(false, test);
160-
} else if ("lexnew".equals(test)) {
167+
break;
168+
case "lexnew":
161169
testCSVLexer(true, test);
162-
} else if (test.startsWith("CSVLexer")) {
163-
testCSVLexer(false, test);
164-
} else if ("extb".equals(test)) {
165-
testExtendedBuffer(false);
166-
} else if ("exts".equals(test)) {
167-
testExtendedBuffer(true);
168-
} else {
169-
System.out.printf("Invalid test name: %s%n", test);
170+
break;
171+
default:
172+
if (test.startsWith("CSVLexer")) {
173+
testCSVLexer(false, test);
174+
} else if ("extb".equals(test)) {
175+
testExtendedBuffer(false);
176+
} else if ("exts".equals(test)) {
177+
testExtendedBuffer(true);
178+
} else {
179+
System.out.printf("Invalid test name: %s%n", test);
180+
}
181+
break;
170182
}
171183
}
172184
}

0 commit comments

Comments
 (0)