Optimisation getIndex of Hashmap