Convert cascading if-else to switch

This commit is contained in:
Gary Gregory 2024-09-12 08:34:52 -04:00
parent af49daadc6
commit 723a5c9320
1 changed files with 28 additions and 16 deletions

View File

@ -143,30 +143,42 @@ public class PerformanceTest {
System.out.printf("Max count: %d%n%n", max); System.out.printf("Max count: %d%n%n", max);
for (final String test : tests) { for (final String test : tests) {
if ("file".equals(test)) { switch (test) {
case "file":
testReadBigFile(false); testReadBigFile(false);
} else if ("split".equals(test)) { break;
case "split":
testReadBigFile(true); testReadBigFile(true);
} else if ("csv".equals(test)) { break;
case "csv":
testParseCommonsCSV(); testParseCommonsCSV();
} else if ("csv-path".equals(test)) { break;
case "csv-path":
testParsePath(); testParsePath();
} else if ("csv-path-db".equals(test)) { break;
case "csv-path-db":
testParsePathDoubleBuffering(); testParsePathDoubleBuffering();
} else if ("csv-url".equals(test)) { break;
case "csv-url":
testParseURL(); testParseURL();
} else if ("lexreset".equals(test)) { break;
case "lexreset":
testCSVLexer(false, test); testCSVLexer(false, test);
} else if ("lexnew".equals(test)) { break;
case "lexnew":
testCSVLexer(true, test); testCSVLexer(true, test);
} else if (test.startsWith("CSVLexer")) { break;
testCSVLexer(false, test); default:
} else if ("extb".equals(test)) { if (test.startsWith("CSVLexer")) {
testExtendedBuffer(false); testCSVLexer(false, test);
} else if ("exts".equals(test)) { } else if ("extb".equals(test)) {
testExtendedBuffer(true); testExtendedBuffer(false);
} else { } else if ("exts".equals(test)) {
System.out.printf("Invalid test name: %s%n", test); testExtendedBuffer(true);
} else {
System.out.printf("Invalid test name: %s%n", test);
}
break;
} }
} }
} }