[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to clone a table in LJ2-friendly way?
- From: Alexander Gladysh <agladysh@...>
- Date: Sat, 27 Aug 2011 11:29:01 +0400
On Sat, Aug 27, 2011 at 10:55, Dirk Laurie <dpl@sun.ac.za> wrote:
> On Fri, Aug 26, 2011 at 07:17:10PM +0200, Alexander Gladysh wrote:
>> On Fri, Aug 26, 2011 at 21:09, Mike Pall <mikelu-1108@mike.de> wrote:
>> > pairs() will not be fast, no matter what I do.
>> So, any code that uses pairs() is bound to be interpreter-only, is this
>> correct?
> pairs() traverses all actually used entries in a hash table. Although
> in theory it takes O(n) time to traverse n pairs, in practice the big-O
> hides a fairly substantial factor compared to ipairs(). Even if you
> hand-code everything directly in assembler (which LuaJIT nearly does).
I most likely am missing something about how LuaJIT works, so please
correct me if I'm wrong:
1. I'm content with the fact that the pairs() would always be slow.
2. However, if pairs() abort the trace of any function...
3. ...Then that *any* function may never be compiled to the native code.
4. And that function may do something complex and optimizable besides
calling pairs()...
5. ...Which would never be optimized due to #3.
So, should I, for example, move the body of a loop with pairs() to the
separate function so it would be compiled? Or what?
Alexander.
- References:
- How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Mike Pall
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dirk Laurie