提交 003fea5c authored 作者: LaughingMan's avatar LaughingMan

Replace MathUtils.compareLong() by Long.compare()

上级 87817179
...@@ -143,7 +143,7 @@ public class MultiVersionCursor implements Cursor { ...@@ -143,7 +143,7 @@ public class MultiVersionCursor implements Cursor {
// version would be compared as well // version would be compared as well
long k1 = deltaRow.getKey(); long k1 = deltaRow.getKey();
long k2 = baseRow.getKey(); long k2 = baseRow.getKey();
compare = MathUtils.compareLong(k1, k2); compare = Long.compare(k1, k2);
} }
if (compare == 0) { if (compare == 0) {
if (isDeleted) { if (isDeleted) {
......
...@@ -46,7 +46,7 @@ public class ConvertTraceFile extends Tool { ...@@ -46,7 +46,7 @@ public class ConvertTraceFile extends Tool {
if (other == this) { if (other == this) {
return 0; return 0;
} }
int c = MathUtils.compareLong(other.time, time); int c = Long.compare(other.time, time);
if (c == 0) { if (c == 0) {
c = MathUtils.compareInt(other.executeCount, executeCount); c = MathUtils.compareInt(other.executeCount, executeCount);
if (c == 0) { if (c == 0) {
......
...@@ -291,18 +291,6 @@ public class MathUtils { ...@@ -291,18 +291,6 @@ public class MathUtils {
return a == b ? 0 : a < b ? -1 : 1; return a == b ? 0 : a < b ? -1 : 1;
} }
/**
* Compare two values. Returns -1 if the first value is smaller, 1 if
* bigger, and 0 if equal.
*
* @param a the first value
* @param b the second value
* @return the result
*/
public static int compareLong(long a, long b) {
return a == b ? 0 : a < b ? -1 : 1;
}
/** /**
* Get a cryptographically secure pseudo random long value. * Get a cryptographically secure pseudo random long value.
* *
......
...@@ -12,7 +12,6 @@ import java.sql.SQLException; ...@@ -12,7 +12,6 @@ import java.sql.SQLException;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
...@@ -121,7 +120,7 @@ public class ValueDate extends Value { ...@@ -121,7 +120,7 @@ public class ValueDate extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
return MathUtils.compareLong(dateValue, ((ValueDate) o).dateValue); return Long.compare(dateValue, ((ValueDate) o).dateValue);
} }
@Override @Override
......
...@@ -12,7 +12,6 @@ import java.sql.SQLException; ...@@ -12,7 +12,6 @@ import java.sql.SQLException;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.MathUtils;
/** /**
* Implementation of the BIGINT data type. * Implementation of the BIGINT data type.
...@@ -171,7 +170,7 @@ public class ValueLong extends Value { ...@@ -171,7 +170,7 @@ public class ValueLong extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
ValueLong v = (ValueLong) o; ValueLong v = (ValueLong) o;
return MathUtils.compareLong(value, v.value); return Long.compare(value, v.value);
} }
@Override @Override
......
...@@ -11,7 +11,6 @@ import java.sql.Time; ...@@ -11,7 +11,6 @@ import java.sql.Time;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
...@@ -129,7 +128,7 @@ public class ValueTime extends Value { ...@@ -129,7 +128,7 @@ public class ValueTime extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
return MathUtils.compareLong(nanos, ((ValueTime) o).nanos); return Long.compare(nanos, ((ValueTime) o).nanos);
} }
@Override @Override
......
...@@ -16,7 +16,6 @@ import org.h2.api.ErrorCode; ...@@ -16,7 +16,6 @@ import org.h2.api.ErrorCode;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
import org.h2.util.MathUtils;
/** /**
* Implementation of the TIMESTAMP data type. * Implementation of the TIMESTAMP data type.
...@@ -310,11 +309,11 @@ public class ValueTimestamp extends Value { ...@@ -310,11 +309,11 @@ public class ValueTimestamp extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
ValueTimestamp t = (ValueTimestamp) o; ValueTimestamp t = (ValueTimestamp) o;
int c = MathUtils.compareLong(dateValue, t.dateValue); int c = Long.compare(dateValue, t.dateValue);
if (c != 0) { if (c != 0) {
return c; return c;
} }
return MathUtils.compareLong(timeNanos, t.timeNanos); return Long.compare(timeNanos, t.timeNanos);
} }
@Override @Override
......
...@@ -14,7 +14,6 @@ import org.h2.api.ErrorCode; ...@@ -14,7 +14,6 @@ import org.h2.api.ErrorCode;
import org.h2.api.TimestampWithTimeZone; import org.h2.api.TimestampWithTimeZone;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
...@@ -310,14 +309,14 @@ public class ValueTimestampTimeZone extends Value { ...@@ -310,14 +309,14 @@ public class ValueTimestampTimeZone extends Value {
b -= t.timeZoneOffsetMins; b -= t.timeZoneOffsetMins;
// compare date // compare date
int c = MathUtils.compareLong(a, b); int c = Long.compare(a, b);
if (c != 0) { if (c != 0) {
return c; return c;
} }
// compare time // compare time
long na = timeNanos - (ma * 1000L * 1000L * 1000L * 60L); long na = timeNanos - (ma * 1000L * 1000L * 1000L * 60L);
long nb = t.timeNanos - (mb * 1000L * 1000L * 1000L * 60L); long nb = t.timeNanos - (mb * 1000L * 1000L * 1000L * 60L);
return MathUtils.compareLong(na, nb); return Long.compare(na, nb);
} }
@Override @Override
......
...@@ -159,7 +159,7 @@ public class ValueUuid extends Value { ...@@ -159,7 +159,7 @@ public class ValueUuid extends Value {
} }
ValueUuid v = (ValueUuid) o; ValueUuid v = (ValueUuid) o;
if (high == v.high) { if (high == v.high) {
return MathUtils.compareLong(low, v.low); return Long.compare(low, v.low);
} }
return high > v.high ? 1 : -1; return high > v.high ? 1 : -1;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论