From a2efa6ec16828c0424481cac57d3425758ca0dc3 Mon Sep 17 00:00:00 2001 From: Christopher Lambert Date: Tue, 7 Feb 2023 18:52:21 +0100 Subject: [PATCH] Break loops when result can no longer change (#728) (Code cleanup/optimization) --- .../com/uber/nullaway/dataflow/AccessPathNullnessAnalysis.java | 1 + .../java/com/uber/nullaway/handlers/LibraryModelsHandler.java | 1 + 2 files changed, 2 insertions(+) diff --git a/nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessAnalysis.java b/nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessAnalysis.java index a0017b2654..e68f05e8b5 100644 --- a/nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessAnalysis.java +++ b/nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessAnalysis.java @@ -231,6 +231,7 @@ public NullnessStore getNullnessInfoBeforeNewContext( if (!e.getKind().equals(ElementKind.FIELD) || !e.getModifiers().contains(Modifier.FINAL)) { allAPNonRootElementsAreFinalFields = false; + break; } } if (allAPNonRootElementsAreFinalFields) { diff --git a/nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java b/nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java index da79973776..c98f77c2a4 100644 --- a/nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java +++ b/nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java @@ -208,6 +208,7 @@ public NullnessHint onDataflowVisitMethodInvocation( for (int idx : nullImpliesNullIndexes) { if (!inputs.valueOfSubNode(node.getArgument(idx)).equals(NONNULL)) { anyNull = true; + break; } } return anyNull ? NullnessHint.HINT_NULLABLE : NullnessHint.FORCE_NONNULL;