use prehash to avoid rehashing the key in the task cache (#8174)
### Description
This avoids hashing the task type multiple times, e. g. for inserting
after lookup or on rehashing of the hash map
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->