From a9d33c2de8beb4e6b4f1ab6efd0fc1ae161bb9af Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 8 Aug 2020 23:06:36 -0700 Subject: [PATCH] Pulled unsigned masks out to BitConstants class --- core/src/com/riiablo/io/BitConstants.java | 12 ++++++++++++ core/src/com/riiablo/io/BitInput.java | 7 +------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 core/src/com/riiablo/io/BitConstants.java diff --git a/core/src/com/riiablo/io/BitConstants.java b/core/src/com/riiablo/io/BitConstants.java new file mode 100644 index 00000000..7d7523f2 --- /dev/null +++ b/core/src/com/riiablo/io/BitConstants.java @@ -0,0 +1,12 @@ +package com.riiablo.io; + +public class BitConstants { + private BitConstants() {} + + static final long[] UNSIGNED_MASKS = new long[Long.SIZE]; + static { + for (int i = 1; i < Long.SIZE; i++) { + UNSIGNED_MASKS[i] = (UNSIGNED_MASKS[i - 1] << 1) + 1; + } + } +} diff --git a/core/src/com/riiablo/io/BitInput.java b/core/src/com/riiablo/io/BitInput.java index 94453032..e2b6adbb 100644 --- a/core/src/com/riiablo/io/BitInput.java +++ b/core/src/com/riiablo/io/BitInput.java @@ -25,12 +25,7 @@ public class BitInput { private static final int MAX_SAFE_CACHED_BITS = Long.SIZE - Byte.SIZE; - private static final long[] MASKS = new long[Long.SIZE]; - static { - for (int i = 1; i < Long.SIZE; i++) { - MASKS[i] = (MASKS[i - 1] << 1) + 1; - } - } + private static final long[] MASKS = BitConstants.UNSIGNED_MASKS; private final ByteInput byteInput; private final long numBits;