lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 18 Aug 2010 07:15:03 -0400
Patrick McCavery <patrick@cakeandfile.com> wrote:

> None of my programs are "Lightroom" in size. Is it such a big deal to 
> keep track of let's say 100 globals? What is the specific threshold
> for pollution?

It's difficult to put a number on it.  Personally, I avoid globals
unless it's absolutely necessary.

> Everyone says globals are slower, any guesses on specifically how
> much slower? i.e half the speed of locals?

It's easy to test.  But remember that globals involve a hash table
lookup in the function's environment table, where locals are just a
register.  Also remember that there are a finite number of registers
available.

In other words, I think it boils down to experimentation and personal
taste.

B.