Skip to content

Commit

Permalink
Hostname.java: Optimize Hostname.getSSHUser()
Browse files Browse the repository at this point in the history
Eliminate unnecessary String.substring() invocation.
  • Loading branch information
dcommander committed Nov 25, 2024
1 parent e1f81d2 commit eb5aef1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions java/com/turbovnc/rfb/Hostname.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ public static String getSSHUser(String vncServerName) {
int atPos = vncServerName.lastIndexOf('@');
String sshUser = null;

if (atPos >= 0) {
sshUser = vncServerName.substring(0, atPos);
if (sshUser.length() > 0)
return sshUser;
}
if (atPos > 0)
return vncServerName.substring(0, atPos);
return null;
}

Expand Down

0 comments on commit eb5aef1

Please sign in to comment.