diff options
author | Carsten Hammer | 2020-01-12 15:55:54 +0000 |
---|---|---|
committer | Carsten Hammer | 2020-03-14 15:46:42 +0000 |
commit | 5576f89d007cc3a1b5af1e7ab7f6dd9e079c6d6c (patch) | |
tree | 91274a5cf893823d442996f18dd71840d11edbd1 /tests | |
parent | 2cb567e8029f2e1418fe289eedfaba14a69bb89b (diff) | |
download | eclipse.platform.team-5576f89d007cc3a1b5af1e7ab7f6dd9e079c6d6c.tar.gz eclipse.platform.team-5576f89d007cc3a1b5af1e7ab7f6dd9e079c6d6c.tar.xz eclipse.platform.team-5576f89d007cc3a1b5af1e7ab7f6dd9e079c6d6c.zip |
Use switch over strings where possibleI20200319-0550I20200318-1800I20200318-1400I20200318-1100I20200317-1800I20200316-1800
Change cascades of ifs which can be converted to switch over Strings.
A switch statement might be faster than an if-then-else chain. And it
improves clarity.
The problem with the if..else chain is that I have to look into all the
if conditions to understand what the program is doing. And the variable
might change in the chain processing.
Change-Id: Ia7003e12ff240ea8c7ad63a382123c00786110a7
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java index a94304124..fc835b645 100644 --- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java +++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java @@ -224,12 +224,16 @@ public class PatchTest { patchdataUrl = FileLocator.resolve(patchdataUrl); Map<String, PatchTestConfiguration> map = null; - if (patchdataUrl.getProtocol().equals("file")) { + switch (patchdataUrl.getProtocol()) { + case "file": map = extractNamesForFileProtocol(patchdataUrl); - } else if (patchdataUrl.getProtocol().equals("jar")) { + break; + case "jar": map = extractNamesForJarProtocol(patchdataUrl); - } else { + break; + default: fail("Unknown protocol"); + break; } assertNotNull(map); |