Improve performance of calculateDbgValueHistory.