gnodet commented on code in PR #1220:
URL: https://github.com/apache/maven/pull/1220#discussion_r1314461642


##########
maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java:
##########
@@ -152,14 +150,15 @@ private ClassRealm createRealm(
             List<String> parentImports,
             Map<String, ClassLoader> foreignImports,
             List<Artifact> artifacts) {
-        Set<String> artifactIds = new LinkedHashSet<>();
+        Set<String> artifactIds = new LinkedHashSet<>(artifacts == null ? 0 : 
artifacts.size());
+        List<ClassRealmConstituent> constituents = new ArrayList<>(artifacts 
== null ? 0 : artifacts.size());
 
-        List<ClassRealmConstituent> constituents = new ArrayList<>();
-
-        if (artifacts != null) {
+        if (artifacts != null && !artifacts.isEmpty()) {
             for (Artifact artifact : artifacts) {
                 if (!isProvidedArtifact(artifact)) {
-                    artifactIds.add(getId(artifact));
+                    if (logger.isDebugEnabled()) {
+                        artifactIds.add(getId(artifact));
+                    }

Review Comment:
   I would not make the computation of the artifactIds condition to the log 
level.



##########
maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java:
##########
@@ -301,20 +300,18 @@ private void callDelegates(
     }
 
     private Set<String> populateRealm(ClassRealm classRealm, 
List<ClassRealmConstituent> constituents) {
-        Set<String> includedIds = new LinkedHashSet<>();
+        Set<String> includedIds = new LinkedHashSet<>(constituents.size());
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("Populating class realm " + classRealm.getId());
-        }
+        logger.debug("Populating class realm {}", classRealm.getId());
 
         for (ClassRealmConstituent constituent : constituents) {
             File file = constituent.getFile();
 
-            String id = getId(constituent);
-            includedIds.add(id);
-
             if (logger.isDebugEnabled()) {
-                logger.debug("  Included: " + id);
+                String id = getId(constituent);

Review Comment:
   Same here.  Move back the `includedIds` computation and simply remove the 
`isDebugEnabled()` call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to