lua-users home
lua-l archive

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


2011/4/5 Gaspard Bucher <gaspard@teti.ch>:
> ==== SOLUTION B
> instance = mimas.FileObserver()
> -- set any attribute (I could manage this with __newindex, __index in C++
> but it seems slow).
> instance.watched_files = {}
> function instance:pathChanged(path)
>   -- self == instance
>   -- I can access watched_files
> end
> =====
> The cleanest solution is "B", but there is a pretty big overhead on each
> member access (Lua --> mimas.FileObserver meta table --> C++ binding -->
> __index --> userdata env table). Is there another solution ?

IMHO it's premature optimization to discard that solution. Write a
benchmark, and run it with real-world-istic input. I think the "big
overhead" is a matter of microseconds.