提交 731abc26 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Pass char instead of String to indexOf() and variants where possible

上级 e953ae84
......@@ -269,7 +269,7 @@ public class MVTableEngine implements TableEngine {
MVMap<?, ?> map = store.openMap(mapName);
store.removeMap(map);
} else if (mapName.startsWith("table.") || mapName.startsWith("index.")) {
int id = Integer.parseInt(mapName.substring(1 + mapName.indexOf(".")));
int id = Integer.parseInt(mapName.substring(1 + mapName.indexOf('.')));
if (!objectIds.get(id)) {
ValueDataType keyType = new ValueDataType(null, null, null);
ValueDataType valueType = new ValueDataType(null, null, null);
......
......@@ -120,7 +120,7 @@ class WebThread extends WebApp implements Runnable {
trace(head + ": " + file);
file = getAllowedFile(file);
attributes = new Properties();
int paramIndex = file.indexOf("?");
int paramIndex = file.indexOf('?');
session = null;
if (paramIndex >= 0) {
String attrib = file.substring(paramIndex + 1);
......
......@@ -248,8 +248,8 @@ class FilePathNioMemLZF extends FilePathNioMem {
throw new IllegalArgumentException(path +
" doesn't start with " + getScheme());
}
int idx1 = path.indexOf(":");
int idx2 = path.lastIndexOf(":");
int idx1 = path.indexOf(':');
int idx2 = path.lastIndexOf(':');
final FilePathNioMemLZF p = new FilePathNioMemLZF();
if (idx1 != -1 && idx1 != idx2) {
p.compressLaterCachePercent = Float.parseFloat(path.substring(idx1 + 1, idx2));
......@@ -260,7 +260,7 @@ class FilePathNioMemLZF extends FilePathNioMem {
@Override
protected boolean isRoot() {
return name.lastIndexOf(":") == name.length() - 1;
return name.lastIndexOf(':') == name.length() - 1;
}
@Override
......
......@@ -260,7 +260,7 @@ public class NetUtils {
} else {
address = bind.getHostAddress();
if (bind instanceof Inet6Address) {
if (address.indexOf("%") >= 0) {
if (address.indexOf('%') >= 0) {
address = "localhost";
} else if (address.indexOf(':') >= 0 && !address.startsWith("[")) {
// adds'[' and ']' if required for
......
......@@ -178,7 +178,7 @@ public class ToChar {
format = format.substring(0, format.length() - 2);
}
int v = formatUp.indexOf("V");
int v = formatUp.indexOf('V');
if (v >= 0) {
int digits = 0;
for (int i = v + 1; i < format.length(); i++) {
......
......@@ -500,7 +500,7 @@ public class Coverage {
private void nextDebug() throws IOException {
if (perFunction) {
int i = function.indexOf("(");
int i = function.indexOf('(');
String func = i < 0 ? function : function.substring(0, i);
String fileLine = file + "." + func + "(";
i = file.lastIndexOf('.');
......
......@@ -80,7 +80,7 @@ public class TestAutoServer extends TestBase {
String key = prop.getProperty("id");
String server = prop.getProperty("server");
if (server != null) {
String u2 = url.substring(url.indexOf(";"));
String u2 = url.substring(url.indexOf(';'));
u2 = "jdbc:h2:tcp://" + server + "/" + key + u2;
Connection conn = DriverManager.getConnection(u2, user, password);
conn.close();
......
......@@ -143,7 +143,7 @@ public class WebClient {
*/
String getBaseUrl(String url) {
int idx = url.indexOf("//");
idx = url.indexOf("/", idx + 2);
idx = url.indexOf('/', idx + 2);
if (idx >= 0) {
return url.substring(0, idx);
}
......
......@@ -85,7 +85,7 @@ public class CheckJavadoc {
int lineNumber = 1;
boolean inComment = false;
while (true) {
int next = text.indexOf("\n", pos);
int next = text.indexOf('\n', pos);
if (next < 0) {
break;
}
......
......@@ -181,7 +181,7 @@ public class LinkChecker {
break;
}
int start = idx + " id=\"".length();
int end = html.indexOf("\"", start);
int end = html.indexOf('"', start);
if (end < 0) {
error(fileName, "Expected \" after id= " + html.substring(idx, idx + 100));
}
......@@ -196,11 +196,11 @@ public class LinkChecker {
if (idx < 0) {
break;
}
int start = html.indexOf("\"", idx);
int start = html.indexOf('"', idx);
if (start < 0) {
error(fileName, "Expected \" after href= at " + html.substring(idx, idx + 100));
}
int end = html.indexOf("\"", start + 1);
int end = html.indexOf('"', start + 1);
if (end < 0) {
error(fileName, "Expected \" after href= at " + html.substring(idx, idx + 100));
}
......@@ -237,16 +237,16 @@ public class LinkChecker {
if (idx < 0) {
break;
}
int equals = html.indexOf("=", idx);
int equals = html.indexOf('=', idx);
if (equals < 0) {
error(fileName, "Expected = after <a at " + html.substring(idx, idx + 100));
}
String type = html.substring(idx + 2, equals).trim();
int start = html.indexOf("\"", idx);
int start = html.indexOf('"', idx);
if (start < 0) {
error(fileName, "Expected \" after <a at " + html.substring(idx, idx + 100));
}
int end = html.indexOf("\"", start + 1);
int end = html.indexOf('"', start + 1);
if (end < 0) {
error(fileName, "Expected \" after <a at " + html.substring(idx, idx + 100));
}
......
......@@ -77,7 +77,7 @@ public class WebSite {
return page;
}
String language = "";
int index = fileName.indexOf("_");
int index = fileName.indexOf('_');
if (index >= 0) {
int end = fileName.indexOf('.');
language = fileName.substring(index, end);
......
......@@ -160,7 +160,7 @@ public class FtpControl extends Thread {
}
} else if ("CDUP".equals(command)) {
if (currentDir.length() > 1) {
int idx = currentDir.lastIndexOf("/", currentDir.length() - 2);
int idx = currentDir.lastIndexOf('/', currentDir.length() - 2);
currentDir = currentDir.substring(0, idx + 1);
reply(250, "Ok");
} else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论