From 74bc50125d3a2cb0a7eb8c32118b3f9a9530a361 Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Tue, 21 May 2019 17:04:18 +0200 Subject: 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 Signed-off-by: Matthias Sohn --- .../eclipse/jgit/internal/transport/sshd/JGitClientSession.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'org.eclipse.jgit.ssh.apache/src') 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 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 -- cgit v1.2.3