I know that allocating memory from the stack is faster, But when accessing a variable which is faster Eg:
void fn1()
{
int *p=new int[50];
for(int i=0;i<50;i++)
p+i=i*i;
}
void fn2()
{
int p[50];
for(int i=0;i<50;i++)
p[i]=i*i;
}
which of the above functions will be executed faster?
I asked it because I am creating a game engine in c++ and I have frequent draw calls which are quite small just involving transformation,rotations,etc by matrices so which allocation will most useful for my purpose