Clean up single char indexOf()

This commit is contained in:
zzz
2016-12-02 18:52:37 +00:00
parent 5b31540fe8
commit 5be077e25d
29 changed files with 51 additions and 51 deletions

View File

@@ -380,8 +380,8 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
}
public void runCommand(String cmd, Logging l) {
if (cmd.indexOf(" ") == -1) cmd += " ";
int iii = cmd.indexOf(" ");
if (cmd.indexOf(' ') == -1) cmd += ' ';
int iii = cmd.indexOf(' ');
String cmdname = cmd.substring(0, iii).toLowerCase(Locale.US);
String allargs = cmd.substring(iii + 1);
String[] args = split(allargs, " "); // .split(" "); // java 1.4

View File

@@ -166,14 +166,14 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
_log.debug(getPrefix(requestId) + "Line=[" + line + "]");
if (method == null) { // first line CONNECT blah.i2p:80 HTTP/1.1
int pos = line.indexOf(" ");
int pos = line.indexOf(' ');
if (pos == -1) break; // empty first line
method = line.substring(0, pos);
String request = line.substring(pos + 1);
pos = request.indexOf(":");
pos = request.indexOf(':');
if (pos == -1)
pos = request.indexOf(" ");
pos = request.indexOf(' ');
if (pos == -1) {
host = request;
restofline = "";
@@ -185,7 +185,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
if (host.toLowerCase(Locale.US).endsWith(".i2p")) {
// Destination gets the host name
destination = host;
} else if (host.indexOf(".") != -1) {
} else if (host.indexOf('.') != -1) {
// The request must be forwarded to a outproxy
currentProxy = selectProxy();
if (currentProxy == null) {

View File

@@ -430,7 +430,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
try {
int myPort = Integer.parseInt(key);
String host = (String) e.getValue();
int colon = host.indexOf(":");
int colon = host.indexOf(':');
int port = Integer.parseInt(host.substring(colon + 1));
host = host.substring(0, colon);
InetSocketAddress isa = new InetSocketAddress(host, port);

View File

@@ -167,8 +167,8 @@ public class I2Ping extends I2PTunnelClientBase {
if (line.startsWith("#")) continue; // comments
if (line.startsWith(";")) continue;
if (line.startsWith("!")) continue;
if (line.indexOf("=") != -1) { // maybe file is hosts.txt?
line = line.substring(0, line.indexOf("="));
if (line.indexOf('=') != -1) { // maybe file is hosts.txt?
line = line.substring(0, line.indexOf('='));
}
PingHandler ph = new PingHandler(line, count, localPort, remotePort,
timeout, countPing, reportTimes);

View File

@@ -380,7 +380,7 @@ abstract class IRCFilter {
if("USER".equals(command)) {
if (field.length < 3)
return s; // invalid, allow server response
int idx = field[2].lastIndexOf(":");
int idx = field[2].lastIndexOf(':');
if(idx<0)
return "USER user hostname localhost :realname";
String realname = field[2].substring(idx+1);