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 2024/09/12 12:59:30 UTC

(commons-imaging) 07/22: Use Collections.sort(List)

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

commit 086b3c5ea606d96edc29c68b08a593eab436024a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:24 2024 -0400

    Use Collections.sort(List)
    
    Merge nested if clauses
---
 .../imaging/formats/jpeg/JpegImageParser.java      | 35 +++++++++-------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
index bef6370a..8d46887f 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
@@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets;
 import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -92,7 +93,7 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
             throw new ImagingException("App2 Segments Missing.  Found: " + segments.size() + ", Expected: " + markerCount + ".");
         }
 
-        segments.sort(null);
+        Collections.sort(segments);
 
         final int offset = startWithZero ? 0 : 1;
 
@@ -710,11 +711,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
                     return false;
                 }
 
-                if (marker == JpegConstants.JPEG_APP1_MARKER) {
-                    if (new JpegXmpParser().isXmpJpegSegment(segmentData)) {
-                        result.add(new JpegXmpParser().parseXmpJpegSegment(segmentData));
-                        return false;
-                    }
+                if (marker == JpegConstants.JPEG_APP1_MARKER && new JpegXmpParser().isXmpJpegSegment(segmentData)) {
+                    result.add(new JpegXmpParser().parseXmpJpegSegment(segmentData));
+                    return false;
                 }
 
                 return true;
@@ -754,11 +753,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
                     return false;
                 }
 
-                if (marker == JpegConstants.JPEG_APP1_MARKER) {
-                    if (startsWith(segmentData, JpegConstants.EXIF_IDENTIFIER_CODE)) {
-                        result[0] = true;
-                        return false;
-                    }
+                if (marker == JpegConstants.JPEG_APP1_MARKER && startsWith(segmentData, JpegConstants.EXIF_IDENTIFIER_CODE)) {
+                    result[0] = true;
+                    return false;
                 }
 
                 return true;
@@ -793,11 +790,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
                     return false;
                 }
 
-                if (marker == JpegConstants.JPEG_APP13_MARKER) {
-                    if (new IptcParser().isPhotoshopJpegSegment(segmentData)) {
-                        result[0] = true;
-                        return false;
-                    }
+                if (marker == JpegConstants.JPEG_APP13_MARKER && new IptcParser().isPhotoshopJpegSegment(segmentData)) {
+                    result[0] = true;
+                    return false;
                 }
 
                 return true;
@@ -832,11 +827,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
                     return false;
                 }
 
-                if (marker == JpegConstants.JPEG_APP1_MARKER) {
-                    if (new JpegXmpParser().isXmpJpegSegment(segmentData)) {
-                        result[0] = true;
-                        return false;
-                    }
+                if (marker == JpegConstants.JPEG_APP1_MARKER && new JpegXmpParser().isXmpJpegSegment(segmentData)) {
+                    result[0] = true;
+                    return false;
                 }
 
                 return true;