Previously, in cases were values were expensive to compute and would be used multiple times, a combination of a regular `Map` and a helper function (`getOrDefault()`) was used to ensure values were only computed once. This commit uses a special `Map`-like structure to compute and memoize such expensive values without the need to a helper function. PR Close #34512