lua-users home
lua-l archive

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


Can anyone give some explanation on why the OO syntax is quicker for string ?
Whether it is the case for any objects/classes (user data or lua based
object)  ?

Are the two syntax handled differently in the lua internals and what
might affect performance of one syntax over the other ?


On 5/7/07, Hans Hagen <pragma@wxs.nl> wrote:
Thomas Lauer wrote:
> What's faster: 's:find(...)' or 'string.find(s,...)'?
>
> I did a few preliminary tests and they seem to indicate that the object
> variant is 5 to 10% faster (it's definitely faster to type...). Has
> anyone done a performance analysis about OO calls vs normal calls?
>
i did quite some experiments with it and the 'oo' string calls are
indeed faster

concerning typing, this is true when applied to variables, but on inline
strings it looks kind of weird, compare:

string.format("abc: %s",123)

with

("abc: %s"):something(123)

Hans


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------




--
Olivier Delannoy
ATER
PRiSM Laboratory
Versailles University, FRANCE