diff --git a/src/main/java/com/mojang/datafixers/DataFixUtils.java b/src/main/java/com/mojang/datafixers/DataFixUtils.java index cf8959ae..fb2fbccb 100644 --- a/src/main/java/com/mojang/datafixers/DataFixUtils.java +++ b/src/main/java/com/mojang/datafixers/DataFixUtils.java @@ -14,13 +14,7 @@ private DataFixUtils() { // Based on: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 public static int smallestEncompassingPowerOfTwo(final int input) { - int result = input - 1; - result |= result >> 1; - result |= result >> 2; - result |= result >> 4; - result |= result >> 8; - result |= result >> 16; - return result + 1; + return (-1 >>> Integer.numberOfLeadingZeros(input - 1)) + 1; } // Based on: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2