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:
nmittler 2014-10-20 12:38:08 -07:00
parent bb397c183b
commit 2c95925609

View File

@ -312,9 +312,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;
}
/**