You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/10/15 21:24:26 UTC

[GitHub] [solr] risdenk commented on a diff in pull request #791: Refactor duplicate CLI options

risdenk commented on code in PR #791:
URL: https://github.com/apache/solr/pull/791#discussion_r996356264


##########
solr/core/src/java/org/apache/solr/util/SolrCLI.java:
##########
@@ -438,16 +459,19 @@ private static Options getToolOptions(Tool tool) {
   }
 
   public static Option[] joinOptions(Option[] lhs, Option[] rhs) {
-    List<Option> options = new ArrayList<Option>();
-    if (lhs != null && lhs.length > 0) {
-      for (Option opt : lhs) options.add(opt);
+    if (lhs == null) {
+      return rhs == null ? new Option[0] : rhs;
     }
 
-    if (rhs != null) {
-      for (Option opt : rhs) options.add(opt);
+    if (rhs == null) {
+      return lhs;
     }
 
-    return options.toArray(new Option[0]);
+    Option[] options = new Option[lhs.length + rhs.length];
+    System.arraycopy(lhs, 0, options, 0, lhs.length);

Review Comment:
   `System.arraycopy` is recommended in a few places by intellij inspections. there are some manual array copies throughout the Solr code base that could be fixed.



-- 
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-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org