diff options
author | Carsten Hammer <carsten.hammer@t-online.de> | 2019-05-21 17:04:18 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-12-14 20:42:03 +0100 |
commit | 74bc50125d3a2cb0a7eb8c32118b3f9a9530a361 (patch) | |
tree | 48e86457ef252be344ece68d9558f72fd23b911c /org.eclipse.jgit.ssh.apache/src | |
parent | 1b3a555f667712ece7f17f009b5444862cbac54f (diff) | |
download | jgit-74bc50125d3a2cb0a7eb8c32118b3f9a9530a361.tar.gz jgit-74bc50125d3a2cb0a7eb8c32118b3f9a9530a361.zip |
Replace chain of if statements with switch
and switch over strings where possible. Sometimes if statements are
chained and form a series of comparisons against constants. Using switch
statements improves readability.
Bug: 545856
Change-Id: Iacb78956ee5c20db4d793e6b668508ec67466606
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.ssh.apache/src')
-rw-r--r-- | org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java index 79bd3faa01..be5eaa495d 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java @@ -251,12 +251,13 @@ public class JGitClientSession extends ClientSessionImpl { .getProperty(SshConstants.HOST_KEY_ALGORITHMS); if (hostKeyAlgorithms != null && !hostKeyAlgorithms.isEmpty()) { char first = hostKeyAlgorithms.charAt(0); - if (first == '+') { + switch (first) { + case '+': // Additions make not much sense -- it's either in // defaultSignatures already, or we have no implementation for // it. No point in proposing it. return String.join(",", defaultSignatures); //$NON-NLS-1$ - } else if (first == '-') { + case '-': // This takes wildcard patterns! removeFromList(defaultSignatures, SshConstants.HOST_KEY_ALGORITHMS, @@ -269,7 +270,7 @@ public class JGitClientSession extends ClientSessionImpl { hostKeyAlgorithms)); } return String.join(",", defaultSignatures); //$NON-NLS-1$ - } else { + default: // Default is overridden -- only accept the ones for which we do // have an implementation. List<String> newNames = filteredList(defaultSignatures, @@ -282,6 +283,7 @@ public class JGitClientSession extends ClientSessionImpl { } else { return String.join(",", newNames); //$NON-NLS-1$ } + break; } } // No HostKeyAlgorithms; using default -- change order to put existing |