Clean up YangProvider a bit 26/104626/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Feb 2023 16:38:48 +0000 (17:38 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Feb 2023 16:39:26 +0000 (17:39 +0100)
Use pre-sized builder and do not store the file name, as we are using it
exactly once.

Change-Id: I602b2b0b5db27c3a80096bc65055bc39d19c257c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangProvider.java

index f6cb95c680273bf4f501d5440fc342699646143e..26fa900b05b6fc4cac8796ac3c94ca08b0e589f8 100644 (file)
@@ -32,11 +32,10 @@ abstract class YangProvider {
             // copy project's src/main/yang/*.yang to ${project.builddir}/generated-sources/yang/META-INF/yang/
             // This honors setups like a Eclipse-profile derived one
             final File withMetaInf = new File(generatedYangDir, YangToSourcesProcessor.META_INF_YANG_STRING);
-            final var stateListBuilder = ImmutableList.<FileState>builder();
+            final var stateListBuilder = ImmutableList.<FileState>builderWithExpectedSize(modelsInProject.size());
 
             for (YangTextSchemaSource source : modelsInProject) {
-                final String fileName = source.getIdentifier().toYangFilename();
-                final File file = new File(withMetaInf, fileName);
+                final File file = new File(withMetaInf, source.getIdentifier().toYangFilename());
                 Files.createParentDirs(file);
 
                 stateListBuilder.add(FileState.ofWrittenFile(file, source::copyTo));