Skip to content

Commit 14c4903

Browse files
committed
Lookup key in map only once
1 parent 583aeda commit 14c4903

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/main/java/org/apache/commons/cli/Options.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,8 @@ public List<String> getMatchingOptions(String opt) {
225225
public Option getOption(String opt) {
226226
opt = Util.stripLeadingHyphens(opt);
227227

228-
if (shortOpts.containsKey(opt)) {
229-
return shortOpts.get(opt);
230-
}
231-
232-
return longOpts.get(opt);
228+
final Option option = shortOpts.get(opt);
229+
return option != null ? option : longOpts.get(opt);
233230
}
234231

235232
/**

0 commit comments

Comments
 (0)