Separate out InferredStatementContext.tryToReuseSubstatements() 25/94825/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Jan 2021 18:23:20 +0000 (19:23 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Jan 2021 18:49:41 +0000 (19:49 +0100)
This is a major path, separate it out for further development.

JIRA: YANGTOOLS-1212
Change-Id: Ib376d5cf340b2360d11b061d2be1fb19919266a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java

index b62900b8c926b09023c7701ca601d0582036fb19..99ee7a8cb55ca600e276aeef00d4a2c69dc4ebaa 100644 (file)
@@ -197,11 +197,7 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
 
         // First check if we can reuse the entire prototype
         if (!factory.canReuseCurrent(this, prototype, origSubstatements)) {
-            // FIXME: YANGTOOLS-1067: an incremental improvement here is that we reuse statements that are not affected
-            //                        by us changing parent. For example: if our SchemaPath changed, but the namespace
-            //                        remained the same, 'key' statement should get reused.
-            // Fall back to full instantiation
-            return super.createEffective(factory);
+            return tryToReuseSubstatements(factory, origSubstatements);
         }
 
         // No substatements to deal with, we can freely reuse the original
@@ -244,6 +240,15 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
             effective.stream().map(Entry::getValue));
     }
 
+    private @NonNull E tryToReuseSubstatements(final StatementFactory<A, D, E> factory,
+            final @NonNull Collection<? extends EffectiveStatement<?, ?>> origSubstatements) {
+        // FIXME: YANGTOOLS-1067: an incremental improvement here is that we reuse statements that are not affected
+        //                        by us changing parent. For example: if our SchemaPath changed, but the namespace
+        //                        remained the same, 'key' statement should get reused.
+        // Fall back to full instantiation
+        return super.createEffective(factory);
+    }
+
     private static boolean allReused(final List<Entry<Mutable<?, ?, ?>, Mutable<?, ?, ?>>> entries) {
         for (Entry<Mutable<?, ?, ?>, Mutable<?, ?, ?>> entry : entries) {
             if (entry.getKey() != entry.getValue()) {