c++ - Are multiple sequential array access optimised? -


will c++ compilers automatically optimise following code calculate 3*i once, , increment result, or must programmer code this?

void writetoarray(int i, int a, int b, int c) {    array[3*i][1]=a;    array[3*i][2]=b;    array[3*i][3]=c; } 

when enable optimization, compilers not precompute common index 3*i pointer array + (3*i)*sizeof (*array).


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -