Skip to content

Commit efdc3bd

Browse files
committed
Reuse Integer.BYTES
1 parent a2599e1 commit efdc3bd

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • src/main/java/org/apache/commons/codec/digest

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,10 @@
7474
* @since 1.16
7575
*/
7676
public final class Blake3 {
77-
// TODO: migrate to Integer.BYTES after upgrading to Java 8
78-
private static final int INT_BYTES = Integer.SIZE / Byte.SIZE;
79-
8077
private static final int BLOCK_LEN = 64;
81-
private static final int BLOCK_INTS = BLOCK_LEN / INT_BYTES;
78+
private static final int BLOCK_INTS = BLOCK_LEN / Integer.BYTES;
8279
private static final int KEY_LEN = 32;
83-
private static final int KEY_INTS = KEY_LEN / INT_BYTES;
80+
private static final int KEY_INTS = KEY_LEN / Integer.BYTES;
8481
private static final int OUT_LEN = 32;
8582
private static final int CHUNK_LEN = 1024;
8683
private static final int CHAINING_VALUE_INTS = 8;
@@ -277,7 +274,7 @@ private static int unpackInt(final byte[] buf, final int off) {
277274

278275
private static int[] unpackInts(final byte[] buf, final int nrInts) {
279276
final int[] values = new int[nrInts];
280-
for (int i = 0, off = 0; i < nrInts; i++, off += INT_BYTES) {
277+
for (int i = 0, off = 0; i < nrInts; i++, off += Integer.BYTES) {
281278
values[i] = unpackInt(buf, off);
282279
}
283280
return values;
@@ -388,7 +385,7 @@ void rootOutputBytes(final byte[] out, int offset, int length) {
388385
compress(inputChainingValue, blockWords, blockLength, outputBlockCounter++, flags | ROOT);
389386
int wordCounter = 0;
390387
while (chunkLength > 0) {
391-
final int wordLength = Math.min(INT_BYTES, chunkLength);
388+
final int wordLength = Math.min(Integer.BYTES, chunkLength);
392389
packInt(words[wordCounter++], out, offset, wordLength);
393390
offset += wordLength;
394391
chunkLength -= wordLength;

0 commit comments

Comments
 (0)