lua-users home
lua-l archive

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


Adam D. Moss wrote:
Posti Laatikko wrote:

Since lua is intepreted language i was wondering does variables & funtions
names effect execution speed if names are long?


Nope - they're just strings which are interned and then
compared/hashed by pointer.

But technically a long string takes longer to do the initial hash, right? So I can imagine a situation where a string must be interned at runtime (constructed on-the-fly) and where you might see some runtime performance issues for long strings vs. short strings.

With that said, Lua's string hashing function is awfully efficient, so I think you would have to come up with a pretty unrealistic example to notice the difference.

--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'