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
bb397c183b
commit
2c95925609
@ -312,9 +312,8 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
|
|||||||
* Returns the hashed index for the given key.
|
* Returns the hashed index for the given key.
|
||||||
*/
|
*/
|
||||||
private int hashIndex(int key) {
|
private int hashIndex(int key) {
|
||||||
int length = keys.length;
|
|
||||||
// Allowing for negative keys by adding the length after the first mod operation.
|
// 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