pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1824349 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
Date Thu, 15 Feb 2018 19:45:55 GMT
Author: tilman
Date: Thu Feb 15 19:45:54 2018
New Revision: 1824349

URL: http://svn.apache.org/viewvc?rev=1824349&view=rev
Log:
PDFBOX-4071: use of the relational operators < and > in compareTo methods is verbose
and error-prone and no longer recommended (Effective Java 2018, p69)

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java?rev=1824349&r1=1824348&r2=1824349&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java Thu Feb
15 19:45:54 2018
@@ -295,33 +295,12 @@ public class KerningSubtable
             assert p1.length >= 2;
             assert p2 != null;
             assert p2.length >= 2;
-            int l1 = p1[0];
-            int l2 = p2[0];
-            if (l1 < l2)
+            int cmp1 = Integer.compare(p1[0], p2[0]);
+            if (cmp1 != 0)
             {
-                return -1;
-            }
-            else if (l1 > l2)
-            {
-                return 1;
-            }
-            else
-            {
-                int r1 = p1[1];
-                int r2 = p2[1];
-                if (r1 < r2)
-                {
-                    return -1;
-                }
-                else if (r1 > r2)
-                {
-                    return 1;
-                }
-                else
-                {
-                    return 0;
-                }
+                return cmp1;
             }
+            return Integer.compare(p1[1], p2[1]);
         }
     }
 }



Mime
View raw message