You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2021/05/12 21:32:23 UTC

[commons-imaging] 01/03: [IMAGING-303] Simplify If-else conditions

This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit d06135a1ae3eda4a50f234c056f82381f41ac0c9
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Wed May 12 22:11:44 2021 +0200

    [IMAGING-303] Simplify If-else conditions
---
 .../apache/commons/imaging/formats/tiff/TiffDirectory.java   | 12 ++----------
 .../apache/commons/imaging/formats/xpm/XpmImageParser.java   |  5 +----
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
index 52423c1..ba9407a 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
@@ -147,11 +147,7 @@ public class TiffDirectory extends TiffElement {
     }
 
     public boolean hasJpegImageData() throws ImageReadException {
-        if (null != findField(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT)) {
-            return true;
-        }
-
-        return false;
+        return null != findField(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT);
     }
 
     public boolean hasTiffImageData() throws ImageReadException {
@@ -159,11 +155,7 @@ public class TiffDirectory extends TiffElement {
             return true;
         }
 
-        if (null != findField(TiffTagConstants.TIFF_TAG_STRIP_OFFSETS)) {
-            return true;
-        }
-
-        return false;
+        return null != findField(TiffTagConstants.TIFF_TAG_STRIP_OFFSETS);
     }
 
     /**
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 fc39bdf..43006be 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
@@ -660,10 +660,7 @@ public class XpmImageParser extends ImageParser {
         }
 
         final PaletteFactory paletteFactory = new PaletteFactory();
-        boolean hasTransparency = false;
-        if (paletteFactory.hasTransparency(src, 1)) {
-            hasTransparency = true;
-        }
+        final boolean hasTransparency = paletteFactory.hasTransparency(src, 1);
         SimplePalette palette = null;
         int maxColors = WRITE_PALETTE.length;
         int charsPerPixel = 1;