Reuse found Set 85/109385/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 19 Dec 2023 10:10:14 +0000 (11:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 19 Dec 2023 10:11:08 +0000 (11:11 +0100)
We are just transferring entries here, so let's reuse the single object
and clear() after each pass.

JIRA: MDSAL-669
Change-Id: Ie41ba63087c8ad0fdc5a581a7d7c4c8dc77f8677
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/GeneratorReactor.java

index 57d477d87b234f33879b7cf584a74676fe6639c2..930a14031bfc0cf58e5094e7a4b846ed8b8be990 100644 (file)
@@ -438,13 +438,13 @@ public final class GeneratorReactor extends GeneratorContext implements Mutable
 
         // Secondary passes: if any unprocessed groupings have been marked as used, process their children, potentially
         //                   adding more work
+        final var found = new HashSet<GroupingGenerator>();
         int passes = 2;
         int processed;
         do {
             // Do not process groupings again unless we make some progress
             processed = 0;
 
-            final var found = new HashSet<GroupingGenerator>();
             final var it = remaining.iterator();
             while (it.hasNext()) {
                 final var next = it.next();
@@ -462,6 +462,7 @@ public final class GeneratorReactor extends GeneratorContext implements Mutable
             if (foundSize != 0) {
                 // we have some more groupings to process, shove them into the next iteration
                 remaining.addAll(found);
+                remaining.clear();
             }
 
             passes++;