Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/main/java/com/mojang/datafixers/DataFixUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down