I realized I don't fully understand how Arduino code handles variable lifetime. My tendency is to keep variables in the narrowest scope (which I realize isn't as important in Arduino code, but, habits...). But how inefficient is this?
Given these possible variations:
const int c1 = 2, c2 = 7, c3 = 9;
void functy();
int foo[3] = {c1 | c2, c3, c2 | c3};
static int foo[3] = {c1 | c2, c3, c2 | c3};
const int foo[3] = {c1 | c2, c3, c2 | c3};
....
In case 1, foo is both allocated and initialized each call.
In case 2, foo is allocated only once, but is it initialized on each call?
In case 3 I assume that allocation and initialization are done only once? Is that true?