RocMarshal commented on code in PR #49826:
URL: https://github.com/apache/spark/pull/49826#discussion_r1944349098


##########
launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java:
##########
@@ -46,24 +47,15 @@ static boolean isEmpty(String s) {
 
   /** Joins a list of strings using the given separator. */
   static String join(String sep, String... elements) {
-    StringBuilder sb = new StringBuilder();
-    for (String e : elements) {
-      if (e != null) {
-        if (sb.length() > 0) {
-          sb.append(sep);
-        }
-        sb.append(e);
-      }
-    }
-    return sb.toString();
+    return join(sep, Arrays.stream(elements).toList());

Review Comment:
   Hi, @LuciferYang thanks for your comment and reminding.
   
   > Has its performance improved now?  
   
   As far as the current changes are concerned, I'm afraid there will be no 
performance improvement.
   
   What about changing the line to  following ?
   ```java  
     static String join(String sep, String... elements) {
       return join(sep, Arrays.asList(elements));
     }
   ```
   
   In this way, unnecessary stream construction can be avoided, with only a 
slight increase in the cost of creating and assigning reference values to an 
`ArrayList`.   
   Perhaps this is tolerable in terms of reducing code redundancy.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to