Skip to content

Commit 63ee050

Browse files
committed
Use UNSAFE.getLong() to speed up BitSetMethods#anySet()
1 parent 4ca0ef6 commit 63ee050

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public static boolean isSet(Object baseObject, long baseOffset, int index) {
7373
*/
7474
public static boolean anySet(Object baseObject, long baseOffset, long bitSetWidthInBytes) {
7575
long widthInLong = bitSetWidthInBytes / SIZE_OF_LONG;
76-
for (long i = 0; i <= widthInLong; i++) {
76+
for (int i = 0; i <= widthInLong; i++) {
7777
if (PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + i) != 0) {
7878
return true;
7979
}
8080
}
81-
for (long i = SIZE_OF_LONG * widthInLong; i < bitSetWidthInBytes; i++) {
81+
for (int i = (int)(SIZE_OF_LONG * widthInLong); i < bitSetWidthInBytes; i++) {
8282
if (PlatformDependent.UNSAFE.getByte(baseObject, baseOffset + i) != 0) {
8383
return true;
8484
}

0 commit comments

Comments
 (0)