You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/30 19:53:25 UTC
[commons-imaging] branch master updated: Lookup key in map only once
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-imaging.git
The following commit(s) were added to refs/heads/master by this push:
new 47186dc8 Lookup key in map only once
47186dc8 is described below
commit 47186dc849ed3a5ffe92a4a16acf88ff33f509d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Nov 30 14:53:19 2022 -0500
Lookup key in map only once
---
.../apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java | 6 ++----
.../java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java | 5 +++--
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java
index 8aa73c0a..b0d5b786 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java
@@ -32,9 +32,7 @@ public final class IptcTypeLookup {
}
public static IptcType getIptcType(final int type) {
- if (!IPTC_TYPE_MAP.containsKey(type)) {
- return IptcTypes.getUnknown(type);
- }
- return IPTC_TYPE_MAP.get(type);
+ final IptcType iptcType = IPTC_TYPE_MAP.get(type);
+ return iptcType != null ? iptcType : IptcTypes.getUnknown(type);
}
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
index 93d8ee83..44e2f750 100644
--- a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
@@ -363,8 +363,9 @@ public class XpmImageParser extends ImageParser<XpmImagingParameters> {
}
loadColorNames();
final String colorLowercase = color.toLowerCase(Locale.ENGLISH);
- if (colorNames.containsKey(colorLowercase)) {
- return colorNames.get(colorLowercase);
+ final Integer integer = colorNames.get(colorLowercase);
+ if (integer != null) {
+ return integer;
}
return 0x00000000;
}