OK, so basically let's say we have a Table and we're either trying to retrieve a value using a specific key, or trying to see if our Table contains a specific key.
The normal way I guess would be with a call to hasKey.
Now, what if we're - possibly - going to perform the same lookup many times? Wouldn't it be more practical instead of doing Table.hasKey(someKey) and having the hash value of someKey calculated over and over again, to be able to do a lookup by Hash value? (provided I've already calculated it and stored it somewhere)
Is it even possible? (I've been looking in the sources and specifically into rawGetImpl() from lib/pure/collections/hashcommon.nim, but still not sure how it would be possible to circumvent this....
Create a custom hash for your keys.
import hashes
type Foo = object
id: Hash
proc hash*(x: Foo): hash {.inline.} =
x.id
And now Table[Foo, Bar] will not hash anything.