Slight performance improvement to IntObjectHashMap.hashIndex()
Motivation: Using a needless local copy of keys.length. Modifications: Using keys.length explicitly everywhere. Result: Slight performance improvement of hashIndex.
This commit is contained in:
parent
c6053b8698
commit
76de0a7567
@ -311,9 +311,8 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
|
||||
* Returns the hashed index for the given key.
|
||||
*/
|
||||
private int hashIndex(int key) {
|
||||
int length = keys.length;
|
||||
// Allowing for negative keys by adding the length after the first mod operation.
|
||||
return (key % length + length) % length;
|
||||
return (key % keys.length + keys.length) % keys.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user