It’s often better to overlay caching and other tricks on top of naive implementations than making the implementation more complicated.