提交 a9930a5c authored 作者: LaughingMan's avatar LaughingMan

Replace MathUtils.compareInt() by Integer.compare()

上级 003fea5c
...@@ -21,7 +21,6 @@ import org.h2.table.Column; ...@@ -21,7 +21,6 @@ import org.h2.table.Column;
import org.h2.table.IndexColumn; import org.h2.table.IndexColumn;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.MathUtils;
import org.h2.util.StatementBuilder; import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.Value; import org.h2.value.Value;
...@@ -348,7 +347,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -348,7 +347,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
if (isMultiVersion) { if (isMultiVersion) {
int v1 = rowData.getVersion(); int v1 = rowData.getVersion();
int v2 = compare.getVersion(); int v2 = compare.getVersion();
return MathUtils.compareInt(v2, v1); return Integer.compare(v2, v1);
} }
return 0; return 0;
} }
......
...@@ -10,7 +10,6 @@ import org.h2.engine.SysProperties; ...@@ -10,7 +10,6 @@ import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
import org.h2.util.MathUtils;
/** /**
* The cursor implementation for the multi-version index. * The cursor implementation for the multi-version index.
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
package org.h2.server.web; package org.h2.server.web;
import org.h2.util.MathUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
...@@ -61,7 +60,7 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> { ...@@ -61,7 +60,7 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
@Override @Override
public int compareTo(ConnectionInfo o) { public int compareTo(ConnectionInfo o) {
return -MathUtils.compareInt(lastAccess, o.lastAccess); return -Integer.compare(lastAccess, o.lastAccess);
} }
} }
...@@ -16,7 +16,6 @@ import java.util.StringTokenizer; ...@@ -16,7 +16,6 @@ import java.util.StringTokenizer;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.MathUtils;
import org.h2.util.New; import org.h2.util.New;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Tool; import org.h2.util.Tool;
...@@ -48,7 +47,7 @@ public class ConvertTraceFile extends Tool { ...@@ -48,7 +47,7 @@ public class ConvertTraceFile extends Tool {
} }
int c = Long.compare(other.time, time); int c = Long.compare(other.time, time);
if (c == 0) { if (c == 0) {
c = MathUtils.compareInt(other.executeCount, executeCount); c = Integer.compare(other.executeCount, executeCount);
if (c == 0) { if (c == 0) {
c = sql.compareTo(other.sql); c = sql.compareTo(other.sql);
} }
......
...@@ -77,7 +77,7 @@ public abstract class CacheObject implements Comparable<CacheObject> { ...@@ -77,7 +77,7 @@ public abstract class CacheObject implements Comparable<CacheObject> {
@Override @Override
public int compareTo(CacheObject other) { public int compareTo(CacheObject other) {
return MathUtils.compareInt(getPos(), other.getPos()); return Integer.compare(getPos(), other.getPos());
} }
public boolean isStream() { public boolean isStream() {
......
...@@ -279,18 +279,6 @@ public class MathUtils { ...@@ -279,18 +279,6 @@ public class MathUtils {
} }
} }
/**
* 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 compareInt(int a, int 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.
* *
......
...@@ -10,7 +10,6 @@ import java.sql.SQLException; ...@@ -10,7 +10,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 BYTE data type. * Implementation of the BYTE data type.
...@@ -106,7 +105,7 @@ public class ValueByte extends Value { ...@@ -106,7 +105,7 @@ public class ValueByte extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
ValueByte v = (ValueByte) o; ValueByte v = (ValueByte) o;
return MathUtils.compareInt(value, v.value); return Integer.compare(value, v.value);
} }
@Override @Override
......
...@@ -8,7 +8,6 @@ package org.h2.value; ...@@ -8,7 +8,6 @@ package org.h2.value;
import java.util.Locale; import java.util.Locale;
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;
public class ValueEnum extends ValueEnumBase { public class ValueEnum extends ValueEnumBase {
private static enum Validation { private static enum Validation {
...@@ -57,7 +56,7 @@ public class ValueEnum extends ValueEnumBase { ...@@ -57,7 +56,7 @@ public class ValueEnum extends ValueEnumBase {
@Override @Override
protected int compareSecure(final Value v, final CompareMode mode) { protected int compareSecure(final Value v, final CompareMode mode) {
return MathUtils.compareInt(getInt(), v.getInt()); return Integer.compare(getInt(), v.getInt());
} }
/** /**
......
...@@ -7,7 +7,6 @@ package org.h2.value; ...@@ -7,7 +7,6 @@ package org.h2.value;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.util.MathUtils;
/** /**
* Base implementation of the ENUM data type. * Base implementation of the ENUM data type.
...@@ -35,7 +34,7 @@ public class ValueEnumBase extends Value { ...@@ -35,7 +34,7 @@ public class ValueEnumBase extends Value {
@Override @Override
protected int compareSecure(final Value v, final CompareMode mode) { protected int compareSecure(final Value v, final CompareMode mode) {
return MathUtils.compareInt(getInt(), v.getInt()); return Integer.compare(getInt(), v.getInt());
} }
@Override @Override
......
...@@ -10,7 +10,6 @@ import java.sql.SQLException; ...@@ -10,7 +10,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 INT data type. * Implementation of the INT data type.
...@@ -140,7 +139,7 @@ public class ValueInt extends Value { ...@@ -140,7 +139,7 @@ public class ValueInt extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
ValueInt v = (ValueInt) o; ValueInt v = (ValueInt) o;
return MathUtils.compareInt(value, v.value); return Integer.compare(value, v.value);
} }
@Override @Override
......
...@@ -10,7 +10,6 @@ import java.sql.SQLException; ...@@ -10,7 +10,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 SMALLINT data type. * Implementation of the SMALLINT data type.
...@@ -106,7 +105,7 @@ public class ValueShort extends Value { ...@@ -106,7 +105,7 @@ public class ValueShort extends Value {
@Override @Override
protected int compareSecure(Value o, CompareMode mode) { protected int compareSecure(Value o, CompareMode mode) {
ValueShort v = (ValueShort) o; ValueShort v = (ValueShort) o;
return MathUtils.compareInt(value, v.value); return Integer.compare(value, v.value);
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论