lua-users home
lua-l archive

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

on 2/28/08 2:40 PM, Jerome Vuarand at wrote:

> Alex Davies wrote:
>> Does anyone else think it would be nice to simply have a byte tag
>> stored with each userdata? Couldn't be quicker to check, and it'd
>> have the added benefit of allowing custom metatables per userdata
>> object. (Only useful in a few cases, but still).
> You can do it, add a byte at the beginning or end of the userdata. I
> don't see why it would need to be outside of the userdata.

Storing it in the userdata itself only works if you know that everyone uses
that byte properly which is a slightly harder problem than doing the ID
space management for the fast tag checking.

I added a byte of fast tag checking to Lightroom, but I don't know whether
it's actually worth it in practice. I need to build an alternative based on
checking something in the metatable or based on a fully-weak-table of
proxies and see how the timings work out.