Let me start by saying that this is more a question about principle
than practice - with the speed of today's computers it's probably
rarely an actual issue. Still I'd like to know...
If I have a function that is called thousands of times per second, it
seems to me that, performance-wise, it would be best to make all
variables used in it global, so that memory for them doesn't have to
be allocated and released with each call. However, I know this
clutters up the name space and can make the code more bug-prone.
Would it ever make sense to use global variables over local ones in
this situation? Would the same answer apply to threads instead of
functions? Thanks for satisfying my curiosity!