gnodet commented on a change in pull request #530:
URL: https://github.com/apache/maven/pull/530#discussion_r716849797



##########
File path: 
maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java
##########
@@ -140,15 +167,13 @@ private void getUpstreamProjects( String projectId, 
Collection<String> projectId
     private List<MavenProject> getSortedProjects( Set<String> projectIds )
     {
         List<MavenProject> result = new ArrayList<>( projectIds.size() );
-
-        for ( MavenProject mavenProject : sorter.getSortedProjects() )
+        for ( String projectId : projectIds )
         {
-            if ( projectIds.contains( ProjectSorter.getId( mavenProject ) ) )
-            {
-                result.add( mavenProject );
-            }
+            result.add( projects.get( projectId ) );
         }
 
+        Collections.sort( result, new MavenProjectComparator() );
+
         return result;

Review comment:
       Precomputing the project ids and their respective order to avoid 
iterating through the list multiple times.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to