提交 dec7fdf7 authored 作者: Thomas Mueller's avatar Thomas Mueller

Small improvements.

上级 14851c03
......@@ -217,7 +217,7 @@ public class FileSystemDisk extends FileSystem {
if (!base.endsWith(File.separator)) {
base += File.separator;
}
for (int i = 0; i < list.length; i++) {
for (int i = 0, len = list.length; i < len; i++) {
list[i] = base + list[i];
}
return list;
......@@ -230,8 +230,10 @@ public class FileSystemDisk extends FileSystem {
fileName = translateFileName(fileName);
if (IOUtils.isDirectory(fileName)) {
String[] list = listFiles(fileName);
for (int i = 0; list != null && i < list.length; i++) {
deleteRecursive(list[i], tryOnly);
if (list != null) {
for (String l : list) {
deleteRecursive(l, tryOnly);
}
}
}
if (tryOnly) {
......
......@@ -966,6 +966,9 @@ public abstract class Table extends SchemaObjectBase {
* 1 otherwise
*/
public int compareTypeSave(Value a, Value b) {
if (a == b) {
return 0;
}
int dataType = Value.getHigherOrder(a.getType(), b.getType());
a = a.convertTo(dataType);
b = b.convertTo(dataType);
......
......@@ -124,8 +124,10 @@ public class Utils {
return -1;
}
int last = bytes.length - pattern.length + 1;
next: for (; start < last; start++) {
for (int i = 0; i < pattern.length; i++) {
int patternLen = pattern.length;
next:
for (; start < last; start++) {
for (int i = 0; i < patternLen; i++) {
if (bytes[start + i] != pattern[i]) {
continue next;
}
......@@ -174,15 +176,16 @@ public class Utils {
if ((test == null) || (good == null)) {
return (test == null) && (good == null);
}
if (test.length != good.length) {
int len = test.length;
if (len != good.length) {
return false;
}
if (test.length == 0) {
if (len == 0) {
return true;
}
// don't use conditional operations inside the loop
int bits = 0;
for (int i = 0; i < good.length; i++) {
for (int i = 0; i < len; i++) {
// this will never reset any bits
bits |= test[i] ^ good[i];
}
......@@ -559,9 +562,10 @@ public class Utils {
}
private static int match(Class<?>[] params, Object[] values) {
if (params.length == values.length) {
int len = params.length;
if (len == values.length) {
int points = 1;
for (int i = 0; i < params.length; i++) {
for (int i = 0; i < len; i++) {
Class<?> pc = getNonPrimitiveClass(params[i]);
Class<?> vc = values[i].getClass();
if (pc == vc) {
......
......@@ -41,7 +41,8 @@ public class ValueHashMap<V> extends HashBase {
Value[] oldKeys = keys;
V[] oldValues = values;
reset(newLevel);
for (int i = 0; i < oldKeys.length; i++) {
int len = oldKeys.length;
for (int i = 0; i < len; i++) {
Value k = oldKeys[i];
if (k != null && k != ValueNull.DELETED) {
put(k, oldValues[i]);
......@@ -169,7 +170,8 @@ public class ValueHashMap<V> extends HashBase {
*/
public ArrayList<V> values() {
ArrayList<V> list = New.arrayList(size);
for (int i = 0; i < keys.length; i++) {
int len = keys.length;
for (int i = 0; i < len; i++) {
Value k = keys[i];
if (k != null && k != ValueNull.DELETED) {
list.add(values[i]);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论