提交 4da501a8 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Push negations down to improve readability

上级 e3f77f71
...@@ -244,7 +244,7 @@ public class Comparison extends Condition { ...@@ -244,7 +244,7 @@ public class Comparison extends Condition {
result = l == ValueNull.INSTANCE; result = l == ValueNull.INSTANCE;
break; break;
case IS_NOT_NULL: case IS_NOT_NULL:
result = !(l == ValueNull.INSTANCE); result = l != ValueNull.INSTANCE;
break; break;
default: default:
throw DbException.throwInternalError("type=" + compareType); throw DbException.throwInternalError("type=" + compareType);
......
...@@ -956,7 +956,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -956,7 +956,7 @@ public class Function extends Expression implements FunctionCall {
result = v0; result = v0;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
Value v = getNullOrValue(session, args, values, i); Value v = getNullOrValue(session, args, values, i);
if (!(v == ValueNull.INSTANCE)) { if (v != ValueNull.INSTANCE) {
result = v.convertTo(dataType); result = v.convertTo(dataType);
break; break;
} }
...@@ -968,7 +968,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -968,7 +968,7 @@ public class Function extends Expression implements FunctionCall {
result = ValueNull.INSTANCE; result = ValueNull.INSTANCE;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
Value v = getNullOrValue(session, args, values, i); Value v = getNullOrValue(session, args, values, i);
if (!(v == ValueNull.INSTANCE)) { if (v != ValueNull.INSTANCE) {
v = v.convertTo(dataType); v = v.convertTo(dataType);
if (result == ValueNull.INSTANCE) { if (result == ValueNull.INSTANCE) {
result = v; result = v;
...@@ -1005,7 +1005,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1005,7 +1005,7 @@ public class Function extends Expression implements FunctionCall {
// (expr, when, then, else) // (expr, when, then, else)
// (expr, when, then, when, then) // (expr, when, then, when, then)
// (expr, when, then, when, then, else) // (expr, when, then, when, then, else)
if (!(v0 == ValueNull.INSTANCE)) { if (v0 != ValueNull.INSTANCE) {
for (int i = 1, len = args.length - 1; i < len; i += 2) { for (int i = 1, len = args.length - 1; i < len; i += 2) {
Value when = args[i].getValue(session); Value when = args[i].getValue(session);
if (database.areEqual(v0, when)) { if (database.areEqual(v0, when)) {
......
...@@ -222,8 +222,7 @@ public class MVStoreTool { ...@@ -222,8 +222,7 @@ public class MVStoreTool {
if (mapId == 0 && details) { if (mapId == 0 && details) {
ByteBuffer data; ByteBuffer data;
if (compressed) { if (compressed) {
boolean fast = !((type & DataUtils.PAGE_COMPRESSED_HIGH) == boolean fast = (type & DataUtils.PAGE_COMPRESSED_HIGH) != DataUtils.PAGE_COMPRESSED_HIGH;
DataUtils.PAGE_COMPRESSED_HIGH);
Compressor compressor = getCompressor(fast); Compressor compressor = getCompressor(fast);
int lenAdd = DataUtils.readVarInt(chunk); int lenAdd = DataUtils.readVarInt(chunk);
int compLen = pageSize + start - chunk.position(); int compLen = pageSize + start - chunk.position();
......
...@@ -177,7 +177,7 @@ public class JdbcUtils { ...@@ -177,7 +177,7 @@ public class JdbcUtils {
if (classFactory.match(className)) { if (classFactory.match(className)) {
try { try {
Class<?> userClass = classFactory.loadClass(className); Class<?> userClass = classFactory.loadClass(className);
if (!(userClass == null)) { if (userClass != null) {
return (Class<Z>) userClass; return (Class<Z>) userClass;
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -542,7 +542,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -542,7 +542,7 @@ public class TestBatchUpdates extends TestBase {
trace("Count val is: " + count); trace("Count val is: " + count);
// make sure that we have the correct error code for // make sure that we have the correct error code for
// the failed update. // the failed update.
if (!(batchUpdates[1] == -3 && count == 1)) { if (batchUpdates[1] != -3 || count != 1) {
fail("insert failed"); fail("insert failed");
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论