문제

Is there a reason to linearize multidimensional arrays into flat for productivity? I mean, even hypothetically you just take pointer operations from compiler and do them explicitly when counting indexes. So what's the point?

도움이 되었습니까?

해결책

Making them flat might make them stay in the CPU cache longer (since they're in the same block of memory), which would reduce the number of cache misses and therefore improve performance. But you'd have to profile and benchmark the code to see exactly what the actual performance implications would be with any particular program. Certainly, I wouldn't worry about that sort of thing unless profiling indicated that you should figure out how to optimize with regards to the jagged arrays in order to reduce a performance bottleneck.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top