lua-users home
lua-l archive

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



On Mar 31, 2007, at 5:42 AM, Graham Wakefield wrote:

The main safety concern would not be necessary if __gc was only visible to the C API, not Lua.  

In my app I must necessarily be concerned with performance; and I also follow the common example of having the metatable equal the method table for this reason.


The number of index operations on tables does not go down when the metatable is the same table as the method table, so I don't see the big performance gain (apart from slightly lower processor cache use maybe?). Lua is still doing 'getmetatable(udata).__index["method"]'. As there is only one instance of each the difference in memory use is insubstantial, and you'd be unable to gain access to __gc if you set __metatable.

I performed a little test, and sharing the method table and metatable was actually 2.5% slower, I don't know why.


--
Gé Weijers