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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4ca1ae68 Avoid calculations the minimum or the maximum of two numbers 
manually.Use Math.max() or Math.min().
     new 9225fac3 Merge pull request #124 from arturobernalg/feature/min_max
4ca1ae68 is described below

commit 4ca1ae688fea9308f213fda3b7090ebfd5445834
Author: Arturo Bernal <[email protected]>
AuthorDate: Sat Apr 16 23:32:26 2022 +0200

    Avoid calculations the minimum or the maximum of two numbers manually.Use 
Math.max() or Math.min().
---
 src/main/java/org/apache/commons/codec/binary/BaseNCodec.java | 4 +---
 src/main/java/org/apache/commons/codec/digest/Md5Crypt.java   | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java 
b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index 6595c0bb..d74e2f54 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -232,9 +232,7 @@ public abstract class BaseNCodec implements BinaryEncoder, 
BinaryDecoder {
         // Integer.MAX_VALUE length array.
         // The result is that we may have to allocate an array of this size 
more than once if
         // the capacity must be expanded again.
-        return (minCapacity > MAX_BUFFER_SIZE) ?
-            minCapacity :
-            MAX_BUFFER_SIZE;
+        return Math.max(minCapacity, MAX_BUFFER_SIZE);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java 
b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
index 82011a2d..2c1802ae 100644
--- a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
@@ -323,7 +323,7 @@ public class Md5Crypt {
         byte[] finalb = ctx1.digest();
         int ii = keyLen;
         while (ii > 0) {
-            ctx.update(finalb, 0, ii > 16 ? 16 : ii);
+            ctx.update(finalb, 0, Math.min(ii, 16));
             ii -= 16;
         }
 

Reply via email to