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 c6053b8698
commit 76de0a7567

View File

@ -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;
}
/**