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


##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java:
##########
@@ -225,10 +225,10 @@ else if ( numTokens == 3 )
             plugin = findPluginForPrefix( prefix, session );
         }
 
-        int executionIdx = goal.indexOf( '@' );
+        int executionIdx = goal.toString().indexOf( '@' );

Review Comment:
   maybe `goal.indexOf( "@" )` to avoid the string conversion ?



##########
maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java:
##########
@@ -225,10 +225,10 @@ else if ( numTokens == 3 )
             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 like the kind of operation we'd like to avoid : a conversion to 
String, and a conversion back to a StringBuilder.  Use `goal.setLength( 
executionIdx )` ?
   Not sure of the overall benefit if we manipulate `StringBuilder` to avoid a 
few string manipulation.   Maybe the use of the `StringBuilder` could be 
limited to refactoring the following code:
   ```
                goal = tok.nextToken();
   
                // This won't be valid, but it constructs something easy to 
read in the error message
                while ( tok.hasMoreTokens() )
                {
                    goal += ":" + tok.nextToken();
                }
   ```   



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