Advertisement

2D Arrays and Speed

Started by November 09, 2000 12:36 PM
1 comment, last by Ranok 24 years, 2 months ago
When using a 2 dimensional array (such as array[2][2]) is it any slower than using a 1 dimensional array and doing the indexing myself. Would one of these be faster than the other: int a = array[r][c]; or int a = array[r*2 + c];
---Ranok---
If it''s a statically allocated array i.e.
int array[5][4];
then it''s the same speed. The compiler does the same computation for you.
Advertisement
if its not a static array, it takes two derefernces for a 2D array, instead of one deference for a 1d array.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement