use a better lookup than a hash.

with a perfect index function in val, there is no need to hash.
val is an incremented int, starting at 0, with every index up to the current max in use; there is no point in calculating a hash from the int then storing (with potential collisions) in a hashmap, when we can use the known int as a direct index to an array with 0 overhead, and 0 chance of collision.