Split calculateParentRefcount() 90/104190/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 30 Jan 2023 10:01:54 +0000 (11:01 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 30 Jan 2023 10:31:26 +0000 (11:31 +0100)
The real meat of the method operates solely on parent, so split it off
into a dedicated method.

Change-Id: I9e3b8a19d4031372669c454bcbd3fbd5ceb29e07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f1eab654288b106cf7ddb956aa37fb63d446b1b0)

parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java

index 2f64a787637c8f2843624e3bc7079e0282e6d7b7..feebe381a7ce48c1e2b17fa52f212c3d76eefc84 100644 (file)
@@ -880,15 +880,15 @@ abstract class ReactorStmtCtx<A, D extends DeclaredStatement<A>, E extends Effec
 
     private byte calculateParentRefcount() {
         final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
-        if (parent == null) {
-            return PARENTREF_ABSENT;
-        }
+        return parent == null ? PARENTREF_ABSENT : parent.refcountForChild();
+    }
 
+    private byte refcountForChild() {
         // A slight wrinkle here is that our machinery handles only PRESENT -> ABSENT invalidation and we can reach here
         // while inference is still ongoing and hence we may not have a complete picture about existing references. We
         // could therefore end up caching an ABSENT result and then that information becoming stale as a new reference
         // is introduced.
-        if (parent.executionOrder() < ExecutionOrder.EFFECTIVE_MODEL) {
+        if (executionOrder() < ExecutionOrder.EFFECTIVE_MODEL) {
             return PARENTREF_UNKNOWN;
         }
 
@@ -897,9 +897,9 @@ abstract class ReactorStmtCtx<A, D extends DeclaredStatement<A>, E extends Effec
         // - negative (< REFCOUNT_NONE), meaning parent is in some stage of sweeping, hence it does not have
         //   a reference to us
         // - positive (> REFCOUNT_NONE), meaning parent has an explicit refcount which is holding us down
-        final int refs = parent.refcount;
+        final int refs = refcount;
         if (refs == REFCOUNT_NONE) {
-            return parent.parentRefcount();
+            return parentRefcount();
         }
         return refs < REFCOUNT_NONE ? PARENTREF_ABSENT : PARENTREF_PRESENT;
     }