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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -