Skip to content

Commit 4ca1ae6

Browse files
committed
Avoid calculations the minimum or the maximum of two numbers manually.Use Math.max() or Math.min().
1 parent 5f90731 commit 4ca1ae6

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/main/java/org/apache/commons/codec/binary/BaseNCodec.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ private static int createPositiveCapacity(final int minCapacity) {
232232
// Integer.MAX_VALUE length array.
233233
// The result is that we may have to allocate an array of this size more than once if
234234
// the capacity must be expanded again.
235-
return (minCapacity > MAX_BUFFER_SIZE) ?
236-
minCapacity :
237-
MAX_BUFFER_SIZE;
235+
return Math.max(minCapacity, MAX_BUFFER_SIZE);
238236
}
239237

240238
/**

src/main/java/org/apache/commons/codec/digest/Md5Crypt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public static String md5Crypt(final byte[] keyBytes, final String salt, final St
323323
byte[] finalb = ctx1.digest();
324324
int ii = keyLen;
325325
while (ii > 0) {
326-
ctx.update(finalb, 0, ii > 16 ? 16 : ii);
326+
ctx.update(finalb, 0, Math.min(ii, 16));
327327
ii -= 16;
328328
}
329329

0 commit comments

Comments
 (0)