A
A
Hi,
I want to use the advantage of having single allocation of a certain struct
or array but keep it "local".
For example - not to pollute my namespace I like to use a lot of "local"
functions like this:
void Function1()
{
struct TLocalFunction1
{
void operator()(int i)
{
char abc[] = {1,2,3,4,5};
}
} LocalFunction1
// call "local" function
LocalFunction(1);
LocalFunction(2);
// etc...
}
Now the problem is that I think this might be slowing down Function1 because
TLocalFunction1 and char abc are constantly initializing from scratch.
So, might I speed up if I prefix "struct TLocalFunction1" and "char abc"
with the keyword "static" would that speed up the Function1 in terms of no
more multiple allocations of TLocalFunction1 and char abc. Or is that
compiler-dependent?
I want to use the advantage of having single allocation of a certain struct
or array but keep it "local".
For example - not to pollute my namespace I like to use a lot of "local"
functions like this:
void Function1()
{
struct TLocalFunction1
{
void operator()(int i)
{
char abc[] = {1,2,3,4,5};
}
} LocalFunction1
// call "local" function
LocalFunction(1);
LocalFunction(2);
// etc...
}
Now the problem is that I think this might be slowing down Function1 because
TLocalFunction1 and char abc are constantly initializing from scratch.
So, might I speed up if I prefix "struct TLocalFunction1" and "char abc"
with the keyword "static" would that speed up the Function1 in terms of no
more multiple allocations of TLocalFunction1 and char abc. Or is that
compiler-dependent?