diff --git a/java/com/google/turbine/binder/ConstEvaluator.java b/java/com/google/turbine/binder/ConstEvaluator.java index c690498b..dbcb1375 100644 --- a/java/com/google/turbine/binder/ConstEvaluator.java +++ b/java/com/google/turbine/binder/ConstEvaluator.java @@ -806,8 +806,10 @@ private Const.DoubleValue asDouble(int position, Const.Value value) { private Const.Value bitwiseAnd(int position, Const.Value a, Const.Value b) { switch (a.constantTypeKind()) { case BOOLEAN -> { + // We're evaluating constants and aren't required to report errors, so using + // short-circuiting operators is faster and not answer changing. return new Const.BooleanValue( - asBoolean(position, a).value() & asBoolean(position, b).value()); + asBoolean(position, a).value() && asBoolean(position, b).value()); } default -> {} } @@ -824,8 +826,10 @@ private Const.Value bitwiseAnd(int position, Const.Value a, Const.Value b) { private Const.Value bitwiseOr(int position, Const.Value a, Const.Value b) { switch (a.constantTypeKind()) { case BOOLEAN -> { + // We're evaluating constants and aren't required to report errors, so using + // short-circuiting operators is faster and not answer changing. return new Const.BooleanValue( - asBoolean(position, a).value() | asBoolean(position, b).value()); + asBoolean(position, a).value() || asBoolean(position, b).value()); } default -> {} }