Skip to content

Commit 855374b

Browse files
committed
Remove second loop since bitSetWidthInBytes is WORD aligned
1 parent 093b7a4 commit 855374b

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

unsafe/src/main/java/org/apache/spark/unsafe/bitset/BitSetMethods.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,13 @@ public static boolean isSet(Object baseObject, long baseOffset, int index) {
7272
* Returns {@code true} if any bit is set.
7373
*/
7474
public static boolean anySet(Object baseObject, long baseOffset, long bitSetWidthInBytes) {
75+
assert bitSetWidthInBytes % SIZE_OF_LONG == 0;
7576
int widthInLong = (int)(bitSetWidthInBytes / SIZE_OF_LONG);
7677
for (int i = 0; i <= widthInLong; i++) {
7778
if (PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + i) != 0) {
7879
return true;
7980
}
8081
}
81-
for (int i = (int)(SIZE_OF_LONG * widthInLong); i < bitSetWidthInBytes; i++) {
82-
if (PlatformDependent.UNSAFE.getByte(baseObject, baseOffset + i) != 0) {
83-
return true;
84-
}
85-
}
8682
return false;
8783
}
8884

0 commit comments

Comments
 (0)