@@ -17,16 +17,15 @@ Licensed to the Apache Software Foundation (ASF) under one or more
1717
1818package org .apache .commons .cli ;
1919
20+ import static org .apache .commons .cli .Util .EMPTY_STRING_ARRAY ;
21+
2022import java .io .Serializable ;
2123import java .util .ArrayList ;
22- import java .util .Collection ;
2324import java .util .Iterator ;
2425import java .util .LinkedList ;
2526import java .util .List ;
2627import java .util .Properties ;
2728
28- import static org .apache .commons .cli .Util .EMPTY_STRING_ARRAY ;
29-
3029/**
3130 * Represents list of arguments parsed against a {@link Options} descriptor.
3231 * <p>
@@ -125,11 +124,7 @@ public List<String> getArgList() {
125124 * @return remaining items passed in but not parsed as an array.
126125 */
127126 public String [] getArgs () {
128- final String [] answer = new String [args .size ()];
129-
130- args .toArray (answer );
131-
132- return answer ;
127+ return args .toArray (Util .EMPTY_STRING_ARRAY );
133128 }
134129
135130 /**
@@ -225,13 +220,7 @@ public Properties getOptionProperties(final String opt) {
225220 * @return an array of the processed {@link Option}s.
226221 */
227222 public Option [] getOptions () {
228- final Collection <Option > processed = options ;
229-
230- // reinitialize array
231- final Option [] optionsArray = new Option [processed .size ()];
232-
233- // return the array
234- return processed .toArray (optionsArray );
223+ return options .toArray (Option .EMPTY_ARRAY );
235224 }
236225
237226 /**
0 commit comments