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


##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java:
##########
@@ -216,9 +216,9 @@ public MojoDescriptor getMojoDescriptor(String task, 
MavenSession session, Maven
             plugin = findPluginForPrefix(prefix, session);
         }
 
-        int executionIdx = goal.indexOf('@');
+        int executionIdx = goal.toString().indexOf('@');
         if (executionIdx > 0) {
-            goal = goal.substring(0, executionIdx);
+            goal = new StringBuilder(goal.substring(0, executionIdx));

Review Comment:
   That looks inefficient, use `goal.setLength(executionIdx);`



##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java:
##########
@@ -138,7 +138,7 @@ public MojoDescriptor getMojoDescriptor(String task, 
MavenSession session, Maven
             throws PluginNotFoundException, PluginResolutionException, 
PluginDescriptorParsingException,
                     MojoNotFoundException, NoPluginFoundForPrefixException, 
InvalidPluginDescriptorException,
                     PluginVersionResolutionException {
-        String goal = null;
+        StringBuilder goal = null;

Review Comment:
   I think creating the `new StringBuilder()` here and use `append` in the  5 
locations below instead of constructing a `new StringBuilder` would make the 
code more clear.



##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java:
##########
@@ -216,9 +216,9 @@ public MojoDescriptor getMojoDescriptor(String task, 
MavenSession session, Maven
             plugin = findPluginForPrefix(prefix, session);
         }
 
-        int executionIdx = goal.indexOf('@');
+        int executionIdx = goal.toString().indexOf('@');

Review Comment:
   I think wrt performances, it would be better to use `goal.indexOf("@")`



-- 
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