Unverified 提交 b69e832e authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #727 from prashantbhat/PR-03

Integer/Long.compare(x, y) can be used to compare primitive values
......@@ -42,7 +42,7 @@ public class SpatialDataType implements DataType {
}
long la = ((SpatialKey) a).getId();
long lb = ((SpatialKey) b).getId();
return la < lb ? -1 : la > lb ? 1 : 0;
return Long.compare(la, lb);
}
/**
......
......@@ -1323,7 +1323,7 @@ public class ObjectDataType implements DataType {
} else if (type == int.class) {
int a = ((int[]) aObj)[i];
int b = ((int[]) bObj)[i];
x = a == b ? 0 : a < b ? -1 : 1;
x = Integer.compare(a, b);
} else if (type == float.class) {
x = Float.compare(((float[]) aObj)[i],
((float[]) bObj)[i]);
......@@ -1333,7 +1333,7 @@ public class ObjectDataType implements DataType {
} else {
long a = ((long[]) aObj)[i];
long b = ((long[]) bObj)[i];
x = a == b ? 0 : a < b ? -1 : 1;
x = Long.compare(a, b);
}
if (x != 0) {
return x;
......@@ -1349,7 +1349,7 @@ public class ObjectDataType implements DataType {
}
}
}
return aLen == bLen ? 0 : aLen < bLen ? -1 : 1;
return Integer.compare(aLen, bLen);
}
@Override
......
......@@ -116,7 +116,7 @@ public class ValueArray extends Value {
return comp;
}
}
return l > ol ? 1 : l == ol ? 0 : -1;
return Integer.compare(l, ol);
}
@Override
......
......@@ -189,7 +189,7 @@ public class FreeSpaceTree {
@Override
public int compareTo(BlockRange o) {
return start < o.start ? -1 : start > o.start ? 1 : 0;
return Integer.compare(start, o.start);
}
@Override
......
......@@ -30,7 +30,7 @@ public class TestSort extends TestBase {
@Override
public int compare(Long o1, Long o2) {
compareCount.incrementAndGet();
return Long.valueOf(o1 >> 32).compareTo(o2 >> 32);
return Long.compare(o1 >> 32, o2 >> 32);
}
};
......
......@@ -265,7 +265,7 @@ public class TestValue extends TestBase {
values[i] = v;
assertTrue(values[i].compareTypeSafe(values[i], null) == 0);
assertTrue(v.equals(v));
assertEquals(i < 2 ? -1 : i > 2 ? 1 : 0, v.getSignum());
assertEquals(Integer.compare(i, 2), v.getSignum());
}
for (int i = 0; i < d.length - 1; i++) {
assertTrue(values[i].compareTypeSafe(values[i+1], null) < 0);
......
......@@ -167,7 +167,7 @@ public class Indexer {
Collections.sort(pages, new Comparator<Page>() {
@Override
public int compare(Page p0, Page p1) {
return p0.relations == p1.relations ? 0 : p0.relations < p1.relations ? 1 : -1;
return Integer.compare(p1.relations, p0.relations);
}
});
for (int i = 0; i < pages.size(); i++) {
......
......@@ -73,7 +73,7 @@ public class Word {
Collections.sort(weightList, new Comparator<Weight>() {
@Override
public int compare(Weight w0, Weight w1) {
return w0.value < w1.value ? 1 : w0.value == w1.value ? 0 : -1;
return Integer.compare(w1.value, w0.value);
}
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论