Improve C++ fold caching efficiency.