This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
The following commit(s) were added to refs/heads/master by this push:
new 14c4903 Lookup key in map only once
14c4903 is described below
commit 14c4903117534e4e4f20947ce227e1fc7af36511
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Nov 30 10:48:14 2022 -0500
Lookup key in map only once
---
src/main/java/org/apache/commons/cli/Options.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/cli/Options.java
b/src/main/java/org/apache/commons/cli/Options.java
index 6905f8f..f87ca90 100644
--- a/src/main/java/org/apache/commons/cli/Options.java
+++ b/src/main/java/org/apache/commons/cli/Options.java
@@ -225,11 +225,8 @@ public class Options implements Serializable {
public Option getOption(String opt) {
opt = Util.stripLeadingHyphens(opt);
- if (shortOpts.containsKey(opt)) {
- return shortOpts.get(opt);
- }
-
- return longOpts.get(opt);
+ final Option option = shortOpts.get(opt);
+ return option != null ? option : longOpts.get(opt);
}
/**