Memoized diff calculation