Replace usages of short-circuit boolean expressions.
Bug: b/270510095
Change-Id: I5bf67900d73abd26e48ba1c3678f5a0d60fdf8ae
diff --git a/build.gradle b/build.gradle
index 289c67a..b0d3716 100644
--- a/build.gradle
+++ b/build.gradle
@@ -711,7 +711,6 @@
options.errorprone.check('HidingField', CheckSeverity.OFF)
options.errorprone.check('StreamResourceLeak', CheckSeverity.OFF)
options.errorprone.check('CatchAndPrintStackTrace', CheckSeverity.OFF)
- options.errorprone.check('ShortCircuitBoolean', CheckSeverity.OFF)
options.errorprone.check('NonCanonicalType', CheckSeverity.OFF)
options.errorprone.check('UnusedNestedClass', CheckSeverity.OFF)
options.errorprone.check('AmbiguousMethodReference', CheckSeverity.OFF)
diff --git a/d8_r8/main/build.gradle.kts b/d8_r8/main/build.gradle.kts
index 9e65e62..10d4b2b 100644
--- a/d8_r8/main/build.gradle.kts
+++ b/d8_r8/main/build.gradle.kts
@@ -58,7 +58,6 @@
options.errorprone.disable("HidingField")
options.errorprone.disable("StreamResourceLeak")
options.errorprone.disable("CatchAndPrintStackTrace")
- options.errorprone.disable("ShortCircuitBoolean")
options.errorprone.disable("NonCanonicalType")
options.errorprone.disable("UnusedNestedClass")
options.errorprone.disable("AmbiguousMethodReference")
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/PrimaryD8L8IRConverter.java b/src/main/java/com/android/tools/r8/ir/conversion/PrimaryD8L8IRConverter.java
index 39fc23a..cf7a083 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/PrimaryD8L8IRConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/PrimaryD8L8IRConverter.java
@@ -229,12 +229,7 @@
int limit = 11;
for (DexProgramClass clazz : appView.appInfo().classesWithDeterministicOrder()) {
if (!clazz.type.descriptor.startsWith(neverMergePrefix)) {
- boolean hasExceptionPrefix = false;
- for (DexString exceptionPrefix : neverMerge.getExceptionPrefixes()) {
- hasExceptionPrefix =
- hasExceptionPrefix | clazz.type.descriptor.startsWith(exceptionPrefix);
- }
- if (hasExceptionPrefix) {
+ if (hasExceptionPrefix(clazz)) {
continue;
}
if (limit-- < 0) {
@@ -255,6 +250,15 @@
}
}
+ private boolean hasExceptionPrefix(DexProgramClass clazz) {
+ for (DexString exceptionPrefix : neverMerge.getExceptionPrefixes()) {
+ if (clazz.type.descriptor.startsWith(exceptionPrefix)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
void classSynthesisDesugaring(
ExecutorService executorService,
CfClassSynthesizerDesugaringEventConsumer classSynthesizerEventConsumer)
diff --git a/src/main/java/com/android/tools/r8/shaking/ProguardClassSpecification.java b/src/main/java/com/android/tools/r8/shaking/ProguardClassSpecification.java
index dd14eea..1ce8f04 100644
--- a/src/main/java/com/android/tools/r8/shaking/ProguardClassSpecification.java
+++ b/src/main/java/com/android/tools/r8/shaking/ProguardClassSpecification.java
@@ -350,10 +350,11 @@
protected StringBuilder append(StringBuilder builder) {
appendAnnotations(classAnnotations, builder);
- boolean needsSpaceBeforeClassType =
- StringUtils.appendNonEmpty(builder, null, classAccessFlags, null)
- | StringUtils.appendNonEmpty(
- builder, "!", negatedClassAccessFlags.toString().replace(" ", " !"), null);
+ boolean hasAccessFlags = StringUtils.appendNonEmpty(builder, null, classAccessFlags, null);
+ boolean hasNegatedAccessFlags =
+ StringUtils.appendNonEmpty(
+ builder, "!", negatedClassAccessFlags.toString().replace(" ", " !"), null);
+ boolean needsSpaceBeforeClassType = hasAccessFlags || hasNegatedAccessFlags;
if (needsSpaceBeforeClassType) {
builder.append(' ');
}