Skip to content

Commit

Permalink
Remove unnecessary casts
Browse files Browse the repository at this point in the history
  • Loading branch information
skrzypo987 authored and sopel39 committed May 27, 2022
1 parent 15b186d commit aa26c96
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public boolean contains(int position, Page page, int[] hashChannels)
@Override
public boolean contains(int position, Page page, int[] hashChannels, long rawHash)
{
int hashPosition = (int) getHashPosition(rawHash, mask);
int hashPosition = getHashPosition(rawHash, mask);

// look for a slot containing this key
while (groupAddressByHash[hashPosition] != -1) {
Expand Down Expand Up @@ -292,7 +292,7 @@ private int putIfAbsent(int position, Page page)

private int putIfAbsent(int position, Page page, long rawHash)
{
int hashPosition = (int) getHashPosition(rawHash, mask);
int hashPosition = getHashPosition(rawHash, mask);

// look for an empty slot or a slot containing this key
int groupId = -1;
Expand Down Expand Up @@ -412,7 +412,7 @@ private boolean tryRehash()

long rawHash = hashPosition(address);
// find an empty slot for the address
int pos = (int) getHashPosition(rawHash, newMask);
int pos = getHashPosition(rawHash, newMask);
while (newKey[pos] != -1) {
pos = (pos + 1) & newMask;
hashCollisions++;
Expand Down Expand Up @@ -458,9 +458,9 @@ private boolean positionNotDistinctFromCurrentRow(long address, int hashPosition
return hashStrategy.positionNotDistinctFromRow(decodeSliceIndex(address), decodePosition(address), position, page, hashChannels);
}

private static long getHashPosition(long rawHash, int mask)
private static int getHashPosition(long rawHash, int mask)
{
return murmurHash3(rawHash) & mask;
return (int) (murmurHash3(rawHash) & mask); // mask is int so casting is safe
}

private static int calculateMaxFill(int hashSize)
Expand Down

0 comments on commit aa26c96

Please sign in to comment.